I have this code:
window.addEvent('domready', function() {
var li_list = document.getElementById("topmenu").getElementsByTagName("li");
for (var i=0; i<li_list.length; i++) {
li_list[i].onmouseover=function() {
this.className+=" hover";
}
li_list[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" hover\\b"), "");
}
}
})
In IE7-8 it fails: document.getElementById(…) is null or not an object.
In Firefox it works well.
That affect the main menu function of the site: http://paraguasparados.com
Thanks.
On IE, domready can fire before the dom is actually ready. Post.
So then
documentobject is not yet available when your code is executed. (Hence the IE error message “document.getElementById(…) is null or not an object.”)Solution: use a toolkit (jQuery, yui, etc) to provide the equivalent of domready that works on IE and other browsers.