PDA

View Full Version : Netscape Javascript error


SirDevan
02-12-2003, 10:08 PM
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="java script:collapseToggle(0);">Menu</a>
<div id=CollapseMenu0Block0 style="DISPLAY:none">
SubMenu


Any help would be appreciated, driving me crazy here.

Roy Sinclair
02-12-2003, 10:30 PM
Quickest fix:

Change:

var curobj="CollapseMenu0Block" + block

to

var curobj= document.getElementById("CollapseMenu0Block" + block);


Right now it's just a string, not an object reference which is why it fails.

Edit: That would break the IE side of things, to make it work both IE and NS you'll also need to change this line:

folder=ns6?curobj.nextSibling.nextSibling.style:document.all[curobj].style

to

folder=ns6?curobj.nextSibling.nextSibling.style:document.getElementById(curobj).style


The whole function could be rewritten cleaner but this will make it work.