Forum Moderators: open

Message Too Old, No Replies

JavaScript error on IE

Possibly a code error

         

mespejo

11:35 pm on Jul 19, 2006 (gmt 0)

10+ Year Member



Below is the JavaScript I used for styling the menu on my homepage. Can anyone tell me what is wrong with the code? How to edit the code to work on IE. Other browsers displays the page with no error messages. Only with IE 6 and 7. I am not an expert on JavaScript I only copied the code. Your help is much appreciated.

// JavaScript Document
activateMenu = function(nav) {

/* currentStyle restricts the Javascript to IE only */
if (document.all && document.getElementById(nav).currentStyle) {
var navroot = document.getElementById(nav);

/* Get all the list items within the menu */
var lis=navroot.getElementsByTagName("LI");
for (i=0; i<lis.length; i++) {

/* If the LI has another menu level */
if(lis[i].lastChild.tagName=="UL"){

/* assign the function to the LI */
lis[i].onmouseover=function() {

/* display the inner menu */
this.lastChild.style.display="block";
}
lis[i].onmouseout=function() {
this.lastChild.style.display="none";
}
}
}
}
}
window.onload= function(){
/* pass the function the id of the top level UL */
/* remove one, when only using one menu */
activateMenu('nav');
//activateMenu('vertnav');
}

mespejo

1:53 am on Jul 20, 2006 (gmt 0)

10+ Year Member



I managed to resolve the error now, thanks.