jewishj
09-08-2002, 07:24 AM
I am having some trouble creating a cross-browser expandable menu. I am currently using <div> tags using style="display:none". I then use javascript to toggle the display between none and block. This doesn't work perfectly in any browser but IE i'm afraid. Here is my code:
function showMenu(el){
var elem = ""
if(document.layers){
elem=document.layers[el].style;
} else if(document.getElementById){
elem = document.getElementById(el).style;
} else {
elem = eval(el).style;
}
//elem.display == "none" ? elem.display = "block" : elem.display = "none" ;
}
Here's how this function works in various browsers:
IE 6 - Works perfectly
NS 6/7 - The menu will open but not close
NS 4.x - Does nothing and returns errors
Opera 6 - Does nothing and returns no errors
I know there is a way to make this work in all of the browsers listed. Any help is greatly appreciated.
Thanks
function showMenu(el){
var elem = ""
if(document.layers){
elem=document.layers[el].style;
} else if(document.getElementById){
elem = document.getElementById(el).style;
} else {
elem = eval(el).style;
}
//elem.display == "none" ? elem.display = "block" : elem.display = "none" ;
}
Here's how this function works in various browsers:
IE 6 - Works perfectly
NS 6/7 - The menu will open but not close
NS 4.x - Does nothing and returns errors
Opera 6 - Does nothing and returns no errors
I know there is a way to make this work in all of the browsers listed. Any help is greatly appreciated.
Thanks