PDA

View Full Version : Netscape frustrates me


SirDevan
02-06-2003, 10:02 PM
function collapseToggle(block){
var ns6=document.getElementById&&!document.all?1:0
var folder=''
var curobj="CollapseMenu0Block" + block
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj].style
if(folder.display=="none")
folder.display=""
else
folder.display="none"
}

This function above has been driving me batty. It works just fine in Internet Explorer but Netscape says "curobj.nextSibling has no properties" I want my script to work on both viewers. This is just a standard display change for hiding/unhiding data.

Any input would be greatly appreciated.

beetle
02-06-2003, 10:08 PM
That's because of how Gecko's DOM treats textNodes Add this before any child or parent references and you should be okay...

if ( ns6 ) curobj.normalize();

SirDevan
02-06-2003, 11:12 PM
Thanks for such a swift response. Am I just being a newbie javascripter? I did this..

function collapseToggle(block){
var ns6=document.getElementById&&!document.all?1:0
var folder=''
var curobj="CollapseMenu0Block" + block
if(ns6) curobj.normalize();
folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj].style
if(folder.display=="none")
folder.display=""
else
folder.display="none"
}

and the response in Netscape is "curobj.normalize is not a function" No errors in Internet Exploder obviously.

the div id = "CollapseMenu0Block0" thru "CollapseMenu0Block24"

if that helps any.

IE
<a href="javascript:collapseToggle(0);">Menu</a>
<div id=CollapseMenu0Block0 style="DISPLAY:none">
SubMenu
</div>


Thanks for responding :)