Open source software security

JavaScript Cross Browser Layer Show/Hide

30 November -0001

This function allows you to show and hide a layer in both Netscape and Internet Explorer. Use the 'startUp()' function in an onLoad event to avoid haveing to use the 'Start' button.

Demo

:



Code:


<script language="javascript">
	function startUp(){
	ns4 = (document.layers)? true:false
	msie = (document.all)? true:false
	if (ns4)
		{document.layers["showMe"].visibility = "show";
	 	document.layers["showMe"].top = "16";
		}
	if (msie)
		{showMe.style.visibility = "visible";}
	}

	function change(){
		if (ns4)
		{
		  if (document.layers["showMe"].visibility == "show")
			{document.layers["showMe"].visibility = "hide";}
		  else
			{document.layers["showMe"].visibility = "show";}
		}
		else
		  {if (showMe.style.visibility == "visible")
			{showMe.style.visibility = "hidden";}
		   else
			{showMe.style.visibility = "visible";}
		  }
	}
	
</script>

<div id="showMe" style="font-size:small"><script>document.write("You're using " + navigator.appName.toLowerCase())</script></div>
<br><BR>
<form>
	<input type="button" value="Start" onClick="startUp()">
	<input type="button" value="Show/Hide" onClick="change()">
</form>