Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Folding menu not working in IE 5.2

Status
Not open for further replies.

RedRobotHero

Technical User
May 2, 2003
94
CN
I'm using a folding menu from Dynamic Drive. It works fine in IE 6 and Netscape 7, but not in IE 5.2 on the Macintosh. Which is surprising, because the code tests for IE 4. You'd think it wouldn't be relying on anything only available in new browsers.

I don't get any error messages, and the rollovers are still working, but I can't expand the folding list.

Any idea what's doing this?

Here's the code, and a link to the site where I'm using this.


Code:
//Smart Folding Menu tree- By Dynamic Drive (rewritten 03/03/02)
//For full source code and more DHTML scripts, visit [URL unfurl="true"]http://www.dynamicdrive.com[/URL]
//This credit MUST stay intact for use

var head="display:''"

var ns6=document.getElementById&&!document.all
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1

function checkcontained(e){
var iscontained=0
cur=ns6? e.target : event.srcElement
i=0
if (cur.id=="foldheader")
iscontained=1
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0
break
}
cur=ns6? cur.parentNode : cur.parentElement
}

if (iscontained){
var foldercontent=ns6? cur.nextSibling.nextSibling : cur.all.tags("UL")[0]
if (foldercontent.style.display=="none"){
foldercontent.style.display=""
}
else{
foldercontent.style.display="none"
}
}
}

if (ie4||ns6)
document.onclick=checkcontained

(I'm also planning on making it degrade a little more gracefully, so that if the Javascript won't run, it will be open, instead of closed. But that's another story, for another time.)
 
I had the same problem, but fixed it with the following code:

var head="display:''";

var ua=navigator.userAgent.toLowerCase();
var MAC=ua.indexOf('mac')!=-1;
var ns6=document.getElementById&&!document.all;
var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1;

function checkcontained(e){
var iscontained=0;
cur=ns6? e.target : event.srcElement;
i=0;
if (cur.id=="foldheader")
iscontained=1;
else
while (ns6&&cur.parentNode||(ie4&&cur.parentElement)){
if (cur.id=="foldheader"||cur.id=="foldinglist"){
iscontained=(cur.id=="foldheader")? 1 : 0;
break;
}
cur=ns6? cur.parentNode : cur.parentElement;
}

if (iscontained){
var foldercontent=(ns6||MAC)? cur.nextSibling.nextSibling : cur.all.tags("UL")[0];
if (foldercontent.style.display=="none"){
foldercontent.style.display="";
}
else{
foldercontent.style.display="none";
}
}
}

if (ie4||ns6)
document.onclick=checkcontained;


This will fix the problem.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top