Forum Moderators: open

Message Too Old, No Replies

document.all vs document.layers

document.all document.layers

         

webaster

1:31 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



document.all works that for NN6 and above
if u want NN4 to work
you use document.layers too I guess

<script type="text/javascript">

<!--
//credits to Travis from podlob.com
textMenu = {timer : null, current : null};
textMenu.getStyle = function(name){
if(document.getElementById) return document.getElementById(name).style;
else if(document.all) return document.all[name].style;
}
textMenu.show = function(name){
if(this.timer) clearTimeout(this.timer);
this.getStyle(name).visibility = "visible";
this.current = name;
}
textMenu.hide = function(){
this.timer = setTimeout("textMenu.doHide()",1000);
}
textMenu.doHide = function(){
if(this.current){
this.getStyle(this.current).visibility = "hidden";
this.current = null;
}
}
//-->
</script>

jbot

2:17 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



document.all works that for NN6 and above

er ... no, it doesn't. document.all is IE only. document.getElementById is NS6 and above! :)

Rambo Tribble

3:40 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To expand a bit: document.all was introduced in IE4, document.layers in NN4. The various flavors of document.getElement~ are W3C-recommendation compatible, supported by IE5 on and NN6 on. IE has maintained backwards-compatibility with document.all, Netscape, et al., abandoned document.layers after NN4.

webaster

3:56 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



<script type="text/javascript">

<!--
//credits to Travis from podlob.com
textMenu = {timer : null, current : null};
textMenu.getStyle = function(name){
if(document.getElementById) return document.getElementById(name).style;
else if(document.all) return document.all[name].style;
}
textMenu.show = function(name){
if(this.timer) clearTimeout(this.timer);
this.getStyle(name).visibility = "visible";
this.current = name;
}
textMenu.hide = function(){
this.timer = setTimeout("textMenu.doHide()",1000);
}
textMenu.doHide = function(){
if(this.current){
this.getStyle(this.current).visibility = "hidden";
this.current = null;
}
}
//-->
</script>

So this script will do the job I mean show/hide layers

webaster

4:00 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



Imean: So this script will do the job I mean show/hide layers in IE5+ and NN6, safari, mozilla

Rambo Tribble

11:44 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Maybe, but there are no guarantees without testing. One thing the more obscure browsers are noted for is less-than-perfect JavaScript interpreters and less-than-complete implementations of the DOM. (By obscure I mean Safari, Opera, Konqueror and such. Mozilla, et al. and IE are the standards.)