Question : JavaScript Error in IE7 menu hover background does not work

@ http://lab.doede.net/d3/ The hover effect (white rectangle showing up behind link onhover) in the menu does not work in IE7. There is a JavaScript Error:
Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0)
Timestamp: Sun, 25 Jul 2010 08:19:05 UTC


Message: 'document.getElementById(...)' is null or not an object
Line: 24
Char: 21
Code: 0
URI: http://lab.doede.net/d3/


and it is related to this piece of code in the header I have attached.

Any ideas how I can solve this error and make the menu function properly like it does in IE8 and Firefox as well as Safari?
1:
2:
3:
4:
5:
6:
7:
<!--[if lte IE 7]>
    <script type="text/javascript">
    sfHover=function(){var sfEls=document.getElementById("nav").getElementsByTagName("LI");for(var i=0;i<sfEls.length;i++){sfEls[i].onmouseover=function(){this.className+=" sfhover";}
    sfEls[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}}}
    if (window.attachEvent)window.attachEvent("onload",sfHover);
    </script>
    <![endif]-->

Answer : JavaScript Error in IE7 menu hover background does not work

Hey,
Looks like you just had the wrong id on line 24 as id nav does not exist it's navigation.
All the best,
Ian
1:
2:
3:
4:
5:
6:
7:
<!--[if lte IE 7]>
    <script type="text/javascript">
    sfHover=function(){var sfEls=document.getElementById("navigation").getElementsByTagName("LI");for(var i=0;i<sfEls.length;i++){sfEls[i].onmouseover=function(){this.className+=" sfhover";}
    sfEls[i].onmouseout=function(){this.className=this.className.replace(new RegExp(" sfhover\\b"),"");}}}
    if (window.attachEvent)window.attachEvent("onload",sfHover);
    </script>
    <![endif]-->
Random Solutions  
 
programming4us programming4us