Comments on: Suckerfish menus with hide delay The (mostly techie) ramblings of Peter Ryan. Tue, 26 May 2009 16:39:36 +0000 hourly 1 By: jonny Tue, 26 May 2009 16:39:36 +0000 Anyone know how to make a 2 second delay before the first drop down appears on hover?

By: Tim Thu, 22 Jan 2009 14:15:48 +0000 Hahaha. Very good point. I guess I should feel lucky you even reponded, but it’s much appreciated.

Thanks Peter!

By: Peter Ryan Thu, 22 Jan 2009 10:55:25 +0000 Hi Tim,

Are you saying you’re using a different script from the one here? And you want support? For a script I can’t see or know the name of? ;)

Okay… the issue above was because the sf-delay script adds CSS class names to the DOM on all browsers, whereas the original sfhover function only did anything when the browser was IE. The problem is, Firefox (and possibly other browsers) as opposed to IE, will return to the same DOM when you press the back button… so the CSS class names show made the menu visible are still in place. But the JavaScript events that should’ve removed those CSS class names after the delay, have been lost.

So the fix was to force the function that removed the CSS class names to execute when the page unloads. So when the user selects a menu item, the DOM is returned to its original state before the new page is loaded.

Hope that helps some! :D


By: Tim Wed, 21 Jan 2009 18:41:01 +0000 How’s it going. I’m using a slightly different superfish script. I am having the same problem as “carry” in a previous post where everytime I hit the back button the menu along with the sub is present. I don’t have an actual sfHover function within my code. Any insight?


By: Peter Ryan Sat, 03 Jan 2009 02:53:34 +0000 Hi Ryan,

If you find the line that sets the sfEls line and comment it out, like so:

// var sfEls = document.getElementById("nav").getElementsByTagName("li");

and then add these lines in below it:

var sfEls = [], elems, i;

elems = document.getElementById("nav").getElementsByTagName("li");
for (i=0; i<elems.length; i++) sfEls = sfEls.concat(elems[i]);

elems = document.getElementById("nav2").getElementsByTagName("li");
for (i=0; i<elems.length; i++) sfEls = sfEls.concat(elems[i]);

then that should work! This of course assumes your IDs are “nav” and “nav2″, but those are easily changed. If you have more menus then just copy and past those two lines and change the ID as appropriate.

I’ve tested this only in Firefox…. so you might want to check it on other browsers before rolling it out! But it should work fine. ;)

Hope that helps.

By: Ryan Fri, 02 Jan 2009 07:31:25 +0000 Thanks for the great script.

Do you have any idea how to get it working with multiple menus with different ID’s on the same page?

By: max mcdowell Wed, 24 Dec 2008 13:44:39 +0000 Thank you Peter,

It works perfectly, including for-firefox modification, even though I know no javascript and can only cut and paste it.
My three level menu is now calm and usable.


By: Peter Ryan Tue, 11 Nov 2008 19:55:03 +0000 Hi Bill,

It should do… but I’m not familiar with Joomla myself or it’s suckerfish implementation. You might need to change the cssClass from “sfhover” to something else, and you’ll need to remove the existing suckerfish JavaScript, but otherwise, this should be a drop in replacement.

You might want to take account of the comments above to fix a problem with menus remaining open when the user presses the back-button on their browser…. at some point, when I get some free time, I *will* re-work this code!!


By: Bill Tue, 11 Nov 2008 13:15:22 +0000 Thanks very much for this. Newb question: Is it possible to drop this into the suckerfish solution I am using in Joomla?

By: Ryan Tue, 21 Oct 2008 10:10:27 +0000 Thanks for the script. I haven’t tried it out yet, but if it works as well as you describe, then I may integrate it (with credit back to you included) into my ‘Multi-level Navigation Plugin’ for WordPress …

I currently use the Superfish jQuery plugin to implement the delay effect, but your script would be a nice addition for those users who don’t want to use jQuery.

A new version is due out some time before the end of the year so I’ll hopefully get it running with your script by then.