Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IE6 - "is null or not an object"

Status
Not open for further replies.

TheCandyman

Technical User
Sep 9, 2002
761
US
I'm working on a css dropdown menu that uses a little javascript. The problem is in IE6 the menu doesn't work i get this error


Code:
Error: 'document.getElementById(...)' is null or not an object

Here is the full page code, but i don't see why it messes up in IE6 but works in IE7 and FF3

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"><head>[/URL]
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>.</title>
<link rel="stylesheet" href="includes/css/style.css" type="text/css" media="screen" />
<script type="text/javascript">
sfHover = function() {
	[b]var sfEls = document.getElementById("nav").getElementsByTagName("LI");[/b]
	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>
</head>
<body>

<div id="container">
	<div id="header">
		<div id="logo"><a href="[URL unfurl="true"]http://www.WesternRegional.org/2009/">[/URL]
        <span id="logotext">Western Regional<br />Dental Convention</span><br />
        <span id="logotextDate">March 12-14, 2009</span></a></div>
	</div>
	<br class="clear"/>
    
    <div id="menu">
    	<ul>
            <li class="menutop">Home</li>
            <li class="item"><a href="#">Home Page</a></li>
        </ul>
        <ul>
            <li class="menutop">Attendees</li>
            <li class="item"><a href="#">F.A.Q.</a></li>              
            <li class="item"><a href="#">View Speakers</a></li>
            <li class="item"><a href="#">Special Events</a></li>
            <li class="item"><a href="#">Exhibitor Search</a></li>
            <li class="item"><a href="#">Registration</a></li>            
            <li class="item"><a href="#">Send Me Info</a></li>                                              
        </ul>
	</div>
  <br class="clear"/>
  <br class="clear"/>
    <div id="contenu">
      <div id="contenu-mid">
        <h1>General Information</h1>
      </div>
    </div>  
	<div id="contenu-bottom"></div>
	<div id="footer">&copy; 2008</div>
</div>
</body>
</html>
 
Aah - I see you have fixed that in the latest version. Right now though, you're adding a class of 'sfhover' to the LI elements, but that style is never defined in your CSS, so it's having no effect. Presumably you want to duplicate your ':hover' rules to add a '.sfhover. rule as well?

P.S. Why not use nested UL/LIs to denote some sort of structure for your menu? Right now, even though on screen it looks structured, for search engines and screen readers, it's all one long flat list with no structure.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Well, after fighting with it to display correctly in IE6 i dumped it and went with another version that is completely css with IE6 hacks. It's worked great so far even though the first example was simpler. Thanks for looking at it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top