PDA

View Full Version : Suckerfish Dropdown menu bug in IE7



Majoracle
Dec 23rd, 2008, 03:21 AM
I'm not sure how many people using the Suckerfish (Sons of Suckerfish) Dropdown menu have noticed this, but in IE7 (but apparently not IE6 or lower), there's a bug that causes the menu to go nuts if you change the focus while one of the drop down menus is out, the menu remains out. I can't give an example cause I'm testing it on Windows, but you can trigger the bug by clicking and dragging a link from one of the drop down menus to the page background. I've found a couple of sites using the Suckerfish drop down menu that have managed to fix this problem (here (http://www.backloggery.com/) and here (http://www.brownandsharpe.com/)) but I don't know how they did it. Spent about 4 hours trying to figure it out.

CSS

#nav, #nav ul { /* all lists */
padding: 0;
margin: 0;
list-style: none;
line-height: 20px;
}
#nav a {
display: block;
width: 10em;
}
#nav li { /* all list items */
float: left;
width: 10em; /* width needed or else Opera goes nuts */
}
#nav li ul { /* second-level lists */
position: absolute;
background: orange;
width: 10em;
left: -999em; /* using left instead of display to hide menus because display: none isn't read by screen readers */
}
#nav li:hover ul, #nav li.sfhover ul { /* lists nested under hovered list items */
left: auto;
}
#content {
clear: left;
color: #ccc;
}

HTML

<ul id="nav">
<li><a href="#">Percoidei</a>
<ul>
<li><a href="#">Remoras</a></li>
<li><a href="#">Tilefishes</a></li>
<li><a href="#">Bluefishes</a></li>
<li><a href="#">Tigerfishes</a></li>
</ul>
</li>

<li><a href="#">Anabantoidei</a>
<ul>
<li><a href="#">Climbing perches</a></li>
<li><a href="#">Labyrinthfishes</a></li>
<li><a href="#">Kissing gouramis</a></li>
<li><a href="#">Pike-heads</a></li>
<li><a href="#">Giant gouramis</a></li>
</ul>
</li>

<li><a href="#">Gobioidei</a>
<ul>
<li><a href="#">Burrowing gobies</a></li>
<li><a href="#">Dartfishes</a></li>
<li><a href="#">Eellike gobies</a></li>
<li><a href="#">Gobies</a></li>
<li><a href="#">Loach gobies</a></li>
<li><a href="#">Odontobutidae</a></li>
<li><a href="#">Sandfishes</a></li>
<li><a href="#">Schindleriidae</a></li>
<li><a href="#">Sleepers</a></li>
<li><a href="#">Xenisthmidae</a></li>
</ul>
</li>
</ul>

<div id="content">
<p>Lorem ipsum</p>
</div>

JavaScript

<script type="text/javascript"><!--//--><![CDATA[//><!--
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>

I did find this on the subject: http://www.builtfromsource.com/2006/10/23/a-fix-for-suckerfish-dropdowns-in-ie-7/

But I think that ends up breaking it in IE6.

Never mind, figured it out.