perrybond
asked on
Document.layers has no properties error
I have the following code that works OK in IE, but I have just tried it in Firefox and I get the following error:
"Document.layers has no properties"
and the line is:
document.layers[i].visibil ity="hide" ;
I do not understand Javascript. Could anyone explain if and how I can get the Javascript to run?
function closeAllMenusExcept(MenuID )
{
var NoOfMenus=10
for (i=0; i<NoOfMenus; i++ )
{
if (navigator.appName=="Netsc ape"){
if (i != MenuID){
document.layers[i].visibil ity="hide" ;
}else{
document.layers[i].visibil ity="show" ;
}
}else{
var what="menu" + i
if (i != MenuID){
// alert(document.all.item(wh at).innerH TML)
document.all.item(what).st yle.visibi lity="hidd en";
}else{
document.all.item(what).st yle.visibi lity="visi ble";
}
}
}
}
"Document.layers has no properties"
and the line is:
document.layers[i].visibil
I do not understand Javascript. Could anyone explain if and how I can get the Javascript to run?
function closeAllMenusExcept(MenuID
{
var NoOfMenus=10
for (i=0; i<NoOfMenus; i++ )
{
if (navigator.appName=="Netsc
if (i != MenuID){
document.layers[i].visibil
}else{
document.layers[i].visibil
}
}else{
var what="menu" + i
if (i != MenuID){
// alert(document.all.item(wh
document.all.item(what).st
}else{
document.all.item(what).st
}
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if (navigator.appName=="Netsc
to this:
if (document.layers)