Results 1 to 2 of 2

Thread: Display and close script not working for IE

  1. #1
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Display and close script not working for IE

    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.

    Code:
    <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:

    Code:
    <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>

  2. #2
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    IE fixed. Here is the final piece:

    Code:
    <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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •