Click to See Complete Forum and Search --> : Netscape Layers
tobysaville
05-05-2003, 10:15 PM
I am trying to switch layers on and off in netscape, but i keep getting the javascript error:
document.layers has no properties
despite there being 2 layer tags in my page.
This is my code:
<script>
function calledWhenPageIsLoaded()
{
document.layers[0].visibility="hidden";
document.layers[1].visibility="show";
}
</script>
<layer id="wait" >
in the wait tag
</layer>
<layer id="mypage" style="visibility:hidden;">
in the layer tag
</layer>
Any ideas what im doing wrong?
Thanks,
Toby
khalidali63
05-05-2003, 11:00 PM
Tested the same code with ns 4.79
works for me,there may be some other style on your page or layer that is causing problem,you might want to define these layers id attribute in the css section instead of inline( a suggestion)
tobysaville
05-05-2003, 11:51 PM
Really? Damn, i get this error in both Netscape 7 and mozilla 1.3. Any chance of testing it in either one of those?
Thanks,
toby
gil davis
05-06-2003, 05:56 AM
Neither NS 7, NS 6 or Mozilla support the LAYERS array. The LAYER tag was a proprietary NS 4 only object. It was abandoned in favor of the W3C DOM.
tobysaville
05-06-2003, 06:39 PM
ah, that explains it all. thanks gil.
Any pointers on using DOM in place of layers?
Thanks again
Toby
Charles
05-06-2003, 06:44 PM
Just keep in mind that anything that you do with JavaScript will fail on in ten times (http://www.thecounter.com/stats/2003/May/javas.php) and that anything that you do with the W3C DOM will fail even more often than that. Make sure that you have some kind of JavaScript free redundancy on your page.
mf22cs
05-06-2003, 07:27 PM
Try this...
NOTE: Use CSS to assign STYLE instead.
/Marcus
<script language="JavaScript">
<!--
function init() {
document.getElementById("no1").style.visibility="hidden";
document.getElementById("no2").style.visibility="visible";
}
// -->
</script>
<body onload="init();">
<!-- Somewhere in BODY -->
<div id="no1">
// HTML-Content
</div>
<div id="no2" style="visibility:hidden;">
// HTML-Content
</div>
tobysaville
05-06-2003, 08:24 PM
cheers dude, that works a treat.
any web resources that have an API with the DOM JavaScript functions?
thanks,
toby
gil davis
05-07-2003, 06:36 AM
There are two pieces to the puzzle. One is CSS and the other is JavaScript.
There is a roadmap that outlines the objects, properties and methods for NS and IE browsers - see http://www.dannyg.com/ref/jsquickref.html .
You can get the W3C recommendations (tough to read, but definitive authority) on CSS at http://www.w3.org .
You can get info on Javascript 1.5 from Netscape at http://devedge.netscape.com/library/manuals/2000/javascript/1.5/reference/ .
You can get a copy of ECMA-262 reference for JavaScript at http://developer.netscape.com/docs/javascript/e262-pdf.pdf .
tobysaville
05-07-2003, 07:22 PM
gil, thanks heaps for all those references, they were excellent. I was aware of one doc on devedge, but not the rest.
Thanks,
toby