You are here: irt.org | FAQ | DHTML | Q699 [ previous next ]
In Netscape Navigator 4 you can attempt to detect for the existence of the a layer. Here is a snippet of code I use for checking before revealing or highlighting a layer:
<STYLE type="text/css"><!-- .myLayers { position: absolute; visibility: hidden; } //--></STYLE> <SCRIPT TYPE="text/JavaScript" LANGUAGE="JavaScript"><!-- function show(object) { if (document.layers && document.layers[object] != null) document.layers[object].visibility = 'visible'; else if (document.all) document.all[object].style.visibility = 'visible'; } function hide(object) { if (document.layers && document.layers[object] != null) document.layers[object].visibility = 'hidden'; else if (document.all) document.all[object].style.visibility = 'hidden'; } //--></SCRIPT> <A HREF="somewhere.htm" onMouseOver=show('a')" onMouseOut="hide('a')">text link</A> <DIV ID="a" CLASS="myLayers>"Waffle, waffle, waffle!</DIV>
The document.layers[object] != null part detects if the object ('a') exists. If it doesn't then you can be certain that either the browser doesn't support layers, or that the user has disabled style sheet support.