PDA

View Full Version : Display and close script not working for IE



ak7861
10-11-2006, 04:19 AM
Hi,

I have the following script which is for a site map. On mozilla the close and display links work perfectly okay, but for IE it doesnt do anything.


<style>
<!--
.set { display: none; }
-->
</style>
<script type="text/javascript">
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay) {
lay = 'set_'+lay;
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay) {
lay = 'set_'+lay;
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}
</script>

Then in the body I have:


<a href="javascript:showlayer('index');">Site map</a>

<span class="set" id="set_index">
<table align="center" width="675" cellpadding="0" cellspacing="0">
<tr>
<td width="12"><img src="images/ssv3_index_top_left.gif" width="12" height="12" /></td>
<td width="650" align="center" style="border-top: 2px solid #D7D7D7;"><img src="images/spacer.gif" /></td>
<td width="12"><img src="images/ssv3_index_top_right.gif" width="12" height="12" /></td>
</tr>
<tr><td colspan="3" align="center" style="border-left: 2px solid #D7D7D7; border-right: 2px solid #D7D7D7;"><table width="634" border="0" align="center" cellpadding="0" cellspacing="0" class="siteindex">
<tr>
<td valign="top">blah blah site map link</td>
</tr>
</table> <a href="javascript:hidelayer('index');">Close index</a></td>
</tr>
</table></span>

ak7861
10-11-2006, 07:44 PM
IE fixed. Here is the final piece:


<script type="text/javascript">
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay) {
lay = 'set_'+lay;
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
else {
document.getElementById(lay).style.display = "none";
}
}
function showlayer(lay) {
lay = 'set_'+lay;
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
else {
document.getElementById(lay).style.display = "block";
}
}
</script>

Thanks anyway.