27
Apr

JavaScript Dropdown Menu

This lightweight JavaScript drop down menu script (~1.6kb) allows you to easily add smooth transitioning dropdowns to your website. This can be used for navigation, dropdown lists, info panels, etc. The script has been tested working in IE6, IE7, IE8, Firefox, Opera and Safari. The markup for the menu including the mouse events looks like the following.

<dl class="dropdown">
<dt id="one-ddheader" onmouseover="ddMenu('one',1)" onmouseout="ddMenu('one',-1)">Dropdown One</dt>
<dd id="one-ddcontent" onmouseover="cancelHide('one')" onmouseout="ddMenu('one',-1)">
<ul>
<li><a href="#" class="underline">Navigation Item 1</a></li>
<li><a href="#" class="underline">Navigation Item 2</a></li>
<li><a href="#" class="underline">Navigation Item 3</a></li>
<li><a href="#" class="underline">Navigation Item 4</a></li>
<li><a href="#">Navigation Item 5</a></li>
</ul>
</dl>

You can have as many dropdowns on one page as you like. Just be sure and have a unique naming scheme for each menu (i.e. one-ddheader, two-ddheader, etc). The “look and feel” is fully customizable though the CSS and you can replace the unordered list with any content you like if you are not looking for a menu.

Click here for the demo.

Click here to download the source.

Click here for a vertical flyout version of this menu.

By Request: Slideup version demo.

Please report any bugs to michael@leigeber.com.

Update 4/28/2008 - I have updated the HTML and CSS to use a definition list and an unordered list in lieu of the previous div-based layout. Thanks to Paul and Deigo for the suggestion.
Update 4/28/2008 - Fixed flicker issue in FF2 on Mac and “-1″ error in IE when quickly moving from the menu to the browser. Thanks to Philip and Chris for reporting these.
Update 5/16/2008 - Optimized the code reducing size by ~15%.



6 Diggs Spread This

120 Responses


Very good. Thanks very much Michael. I tried it on a page with a couple of mootools snippets and they all got along very well :-) No conflicts.
Keep up the great work!

Neil on 28 Apr 2008 at 2:16 am

Looks very nice! Although I’d rather use a <ul> structure…

Paul on 28 Apr 2008 at 3:55 am

Very good the tutorial. I will use in a new project

Tiago Celestino on 28 Apr 2008 at 6:26 am

@Paul, actually, an ul inside and dl it would be perfect :)

dl
dt Dropdown 1
dd
ul
li Option 1
li Option 2
li Option 3

Diego on 28 Apr 2008 at 8:21 am

@Paul - The content of the dropdown could easily be an unordered list with little modification. Just switch up the HTML a bit and add the appropriate CSS classes.

@Diego - Excellent suggestion. I definately do recommend using existing HTML tags in lieu of classed divs. I will take a look at incorporating those tags and update the post if I like how it works out. I have never actually used definition lists in any project so it will be new to me. Thanks.

Michael on 28 Apr 2008 at 8:32 am

Thanks a lot……… this is very useful for my web designing business.

RedesignYourBiz.com on 28 Apr 2008 at 11:37 am

[...] блог Майкла Лейгебера. Категория: JavaScriptАвтор: Spider Дата: 28 Апрель 2008 Время: [...]

Выпадающие меню на JavaScript | АяксЛайн.ру on 28 Apr 2008 at 4:06 pm

<strong>Sliding JavaScript Dropdown Menu - Web Development Blog…</strong>

This lightweight drop down menu script allows you to easily add smooth transitioning dropdowns to your website This can be used for navigation dropdown lists info panels etc…

roScripts - Webmaster resources and websites on 28 Apr 2008 at 6:15 pm

HA! That is so funny, a friend of mine just sent me a zipped up javascript menu today..and this is it.

VERY easy to customize, a real treat.

Steph on 28 Apr 2008 at 10:23 pm

[...] Sliding JavaScript Dropdown Menu - Web Development Blog (tags: javascript) [...]

Skylog » Blog Archive » links for 2008-04-29 on 29 Apr 2008 at 12:30 am

Very nice Micheal! Works well in IE and FF!

Srikanth on 29 Apr 2008 at 6:13 am

Is it hard to make a submenu with this example?

Augusto on 29 Apr 2008 at 8:46 am

@Augusto - Submenu functionality is not incorporated currently as I wanted to keep it as simple as possible for those that did not need them. It wouldn’t be too difficult to add a popout submenu though. You would treat it as if it were its own independent menu and position it in relation to the top level menu selection. Of course you would also need to cancel the timer on the primary menu when you enter the second level menu. Just shoot me an email if you need assistance.

Michael on 29 Apr 2008 at 8:57 am

awesome
thanks

sumit on 29 Apr 2008 at 10:15 am

Cool, but… what about keyboard navigation? And submenus? Maybe in 2.0 version :)

Walmar on 29 Apr 2008 at 10:43 am

@Walmar - Absolutely, I have had a few requests for submenus so I will get that as well as keyboard navigation added in soon so check back shortly.

Michael on 29 Apr 2008 at 10:49 am

[...] Sliding JavaScript Dropdown Menu - Web Development Blog (tags: javascript menu ajax css navigation dropdown) [...]

links for 2008-04-29 « toonz on 29 Apr 2008 at 5:34 pm

[...] Sliding JavaScript Dropdown Menu - Web Development Blog via kwout [...]

アニメーションつきのドロップダウンメニューを on 29 Apr 2008 at 6:17 pm

[...] This lightweight drop down menu script (~1.8kb) allows you to easily add smooth transitioning dropdowns to your website. This can be used for navigation, dropdown lists, info panels, etc. [...]

StyleCrunch » Blog Archive » Sliding JavaScript Dropdown Menu on 30 Apr 2008 at 1:40 am

Nice work, I hope you are recognized for your efforts. Do you have development on a similar but vertical flyout menu? That would complete the set!

peter on 30 Apr 2008 at 7:01 am

@peter - Thank you. I have a few more scripts on my list and will definately add a flyout menu to it. I am always open to suggestions. Just email me at michael@leigeber.com.

Michael on 30 Apr 2008 at 7:47 am

hi

whats the best way to add a top-level item to this nav that doesn’t have a drop-down menu attached?

cheers
hasta

hasta on 08 May 2008 at 11:12 am

@hasta - I helped someone else with this a few days ago. You can see what I demoed to them at http://sandbox.leigeber.com/dropdown2/dropdown.html. Basically you want to create a block link and float it to the left. Shoot me an email if you run into any problems michael@leigeber.com.

Michael on 08 May 2008 at 12:18 pm

thats great. thanks for the speedy reply
hasta

hasta on 09 May 2008 at 3:36 am

[...] Sliding Dropdown Menu / Javascript [...]

Milestone 01 - 70+ High-End Components for Web Designers and Developers : DevKick Blog on 13 May 2008 at 2:52 pm

How do i sent it to make the menu disply on the right instead of down?

Gary on 15 May 2008 at 11:34 am

@Gary - I have started working on that, hopefully I will finish up in the next couple days. There are a couple issues that make it a little less easy that just changing a couple variables. Feel free to shoot me an email in a couple days if I haven’t posted an update.

Michael on 15 May 2008 at 12:12 pm

Hello. Thanks for that!
;)

Katz on 16 May 2008 at 2:51 am

Is there a way to change direction of the slide down javascript menu? If so how do you do that?

Thanks

Grace on 16 May 2008 at 5:49 pm

@Grace - I hope to have a vertical menu released tonight or tomorrow. If you are looking for something else let me know.

Michael on 16 May 2008 at 7:18 pm

[...] animated JavaScript flyout menu is clean and lightweight at only 1.6kb. This is based on the post a few weeks ago of a horizontal dropdown menu. The markup is the same so visit the horizontal menu post for [...]

Vertical Flyout JavaScript Menu - Web Development Blog on 17 May 2008 at 12:06 am

WOW this is a great script! Would it be difficult to change it to slide up and with a submenu that could slide up also and overlap? or would that just be too hard to configure?

Todd on 17 May 2008 at 8:39 pm

@Todd, I just put together a slide-up version this morning on request at http://sandbox.leigeber.com/dropdown3/dropdown.html. As for the sub-menus, it is definitely on the to-do list. I will shoot you an email when I have it ready.

Michael on 17 May 2008 at 8:52 pm

This is a very nice script i will certanly be using it asap my only concern is accesibility. If the browser dosent support javascript or the user has it turned off the navigation is totaly hidden. I have slightly modified the code to use an onload hide function which solves this. If the comments are removed the modified script is only 1.54kb. Have a look at the modified script @

http://www.t-brown.co.uk/scripts/sliding_dropdown_modified.zip

Tom on 19 May 2008 at 12:29 pm

@Tom - Thanks for the feedback. I am big on accessibility and depending on the implementation and requirements it can be handled differently. You could mesh the script along with an onload and the :hover pseudo-class to create a non-animated dropdown when JS is not present, of course that would require browser support for :hover. Alternatively you could just have the main dropdown link something like this… <a href=”link.html” onclick=”function(); return false;”>link</a> where it could link into a top level page or landing page of some sort. Thanks for sharing the zip.

Michael on 19 May 2008 at 1:01 pm

@Michael - No problem hope it can be of some use to others, congrats again on the great script.

p.s. forgot to mention the slight alteration i made to the list css too:

…<li><a href=”#” class=”top”>Navigation Item 1</a></li>
<li><a href=”#”>…

.dropdown a {border-top:1px solid #b9d6dc;…
.dropdown a.top {border: 0;}

I do alot of work with CMS and styling lists like this makes automated population easyer and saves a few more bytes =)

Tom on 19 May 2008 at 2:45 pm

I had a dropdownmenu on my site but i was not satisfied, but now I do!! This is perfect! It’s very easy to use, thank you very much :).
A satisfied girl from the netherlands :)

Marjolein on 20 May 2008 at 4:35 pm

I’m also from the Netherlands.
I like the menu very mutch and it’s beautiful.

But I have one question about it:
Is it possible to make a sub-sub menu?
A Navigation item 1.1.1?
The first 1 is the Horizantal menu button
The second 1 is the first drop down menu item
The thirt 1 is the sub menu from the second 1.

Joey on 21 May 2008 at 3:21 am

@Joey - Have had this question a few times so I will be adding multi-level support in the next week. I will notify you and others when I have it live. If you cannot wait then it should not be too hard to extend the current script.

Michael on 21 May 2008 at 8:00 am

nice work done, but i need sub-sub menu. hope i’ll get soon…

Sac on 23 May 2008 at 3:48 am

can there be a multi column dropdown version of this script? I’ve been looking around for one for a year and no one has done a sleek dropdown like yours.

sample: johnlewis.com

joachim guanzon on 26 May 2008 at 11:24 am

@joachim guanzon - Shoot me an email I can help you out. You should be able to just modify the CSS and markup to get multiple columns. michael@leigeber.com

Michael on 26 May 2008 at 11:29 am

Hey, just wanted to say I’m using this script for a website I’m designing and it works great. (Though it seems to run slow on Opera and Firefox, for some reason)
I had a semi-outside question, in that I can’t figure out how in the world to center this. Forcing the menu to the left side of the page would work, but centered looks better. =) I’ve tried surrounding it with “margin: 0 auto” divs but that hasn’t helped any. Any ideas?

Thanks.

Slash on 27 May 2008 at 8:13 am

@Slash - Different browsers handle the timeout speed a little differently. In particular IE will usually seem faster than others but it is not performance-related, just how they handle things. I helped someone with a couple issues including centering and you can see it at http://sandbox.leigeber.com/dropdown2/dropdown.html Shoot me an email if you can’t figure it out from viewing the source on that demo.

Michael on 27 May 2008 at 8:32 am

I like this menu a lot, but it’s just got a few things I can’t get working.
> Would it even be possible to get onclick and onblur working? (I know dt doesn’t support onblur).
> Is there an easy way to position the menu? Like, right or left? I’m asking because the dropdown will have multiple instances and they can be on the left and/or right side of the page. Left is fine like it is, but the ones on the right have to have their extra width go left of the ddheader, being pinned to the bottom right corner of the menu.

m3talc0re on 27 May 2008 at 2:22 pm

m3talc0re - The things you mentioned here should not take too much customization. The menu should support whatever mouse events you need and the positioning can be completely controlled through the markup/css, you are not locked in to floating everything to the left. I would be happy to help you, just shoot an email to michael@leigeber.com with a link.

Michael on 27 May 2008 at 2:27 pm

Hi Michael! I need sub sbu menu, will u please tell me when u’ll post that.

-Thank’s

Sac on 28 May 2008 at 4:04 am

@Sac - Certainly, will do my best to get it out this week.

Michael on 28 May 2008 at 8:32 am

Michael,

Thanks for the help previously. I was trying to avoid having to have a fixed pixel width for the page I’m designing, but it looks like that’s the only way to get it to center appropriately.

One more question though, is there any w3c-valid way to make the top entry of the list (that is, the part you rollover to get the rest to drop down) into a link? Putting an anchor around the whole <dl> area works, but the validator gripes at me. =)

Just curious, thanks!

Slash on 28 May 2008 at 9:08 am

@Slash - I believe both of your issues can be resolved. Shoot me an email with a link to where you are now and I will get back to you when I can with my thoughts. michael@leigeber.com

Michael on 28 May 2008 at 9:15 am

This is great, I will use it for one of my client sites.

Cheers!

Tyler on 28 May 2008 at 5:37 pm

@slash,

If it has succeeded to make a link in the head part. May I then have your script so that I also can use a link in the head of the dropdown menu balk.

@michael,
Thanks, that you would make a sub-sub-menu. I’m still waighting at the release.

It’s possible that there are a few language errors are in my comment. Because I live in the Netherlands and my English isn’t very good.

Joey on 29 May 2008 at 8:46 am

I need that selected index would be displayed on the screen and I can’t do this,could you help me,please

Solnyshko on 31 May 2008 at 6:34 am

@Solnyshko - Not sure exactly what you are asking. Shoot me an email with clarification and I will do what I can to help.

Michael on 31 May 2008 at 11:41 am

Hey Michael. Thank you for making your code available, I think a lot of people appreciate it a lot.
Unfortunately I ran into the IE z-Index bug with your menu solution, might be an issue for others too. Send you an eMail.
All the best
Lars

Lars on 02 Jun 2008 at 3:26 am

Hi Michael,
Is there an easy way to make the background of the dropdown menu transparent ?

Cheers !

Stephane on 03 Jun 2008 at 10:11 am

Stephane - To make the background completely transparent you could just remove the background color on the list elements in the CSS.

Michael on 03 Jun 2008 at 10:30 am

Solved my problem by using different positioning for certain design elements.
Thank you

Lars

Lars on 05 Jun 2008 at 9:55 am

Hello folks,

Below is part of a drop-down menu i’ve created for my project. On I.E. Sub-menus onhover appear downwards. May i know what do i need to change on the Javascript/CSS/etc. to make sub-menus onhover to appear to the right side please? Thank you very much for your promt answers.

XHTML:

<ul id=”sddm”>

<li>
<a href=”smoking_index.html”

onmouseover=”mopen(’m1′)”
onmouseout=”mclosetime()”>Living life as an addict</a>

<div id=”m1″

onmouseover=”mcancelclosetime()”
onmouseout=”mclosetime()”>

<a href=”smoker.html”>Who’s a smoker?</a>
<a href=”smokerlife.html”>How’s a smoker’s life like?</a>
<a href=”facts.html”>Facts</a>

</div>
</li>
</ul>

Javascript:

var timeout = 500;
var closetimer = 0;
var ddmenuitem = 0;

function mopen(id)

{ mcancelclosetime();

if(ddmenuitem) ddmenuitem.style.visibility = ‘hidden’;

ddmenuitem = document.getElementById(id);
ddmenuitem.style.visibility = ‘visible’; }

function mclose()

{ if(ddmenuitem) ddmenuitem.style.visibility = ‘hidden’; }

function mclosetime()

{ closetimer = window.setTimeout(mclose, timeout); }

function mcancelclosetime()

{ if(closetimer)

{ window.clearTimeout(closetimer);
closetimer = null; }
}

document.onclick = mclose;

Regards,
Lawrence

Lawrence on 05 Jun 2008 at 10:06 pm

@Lawrence - This may be what you are looking for http://www.leigeber.com/2008/05/vertical-flyout-javascript-menu/

Michael on 06 Jun 2008 at 9:32 am

excellent tool…thanks

Eric on 06 Jun 2008 at 4:57 pm

Hi Michael! This is such a cool dropdown menu. Ive been playing and testing it with succes. But I cant figure out one thing. How can I <a href the main menu items? The way im doing it is wrong cause im getting the submenu css properties.

I hope you can help me with this, Thanks! :-)

Juki -> Netherlands

Juki on 07 Jun 2008 at 5:36 am

@Juki - You would just need to nest a link in the dt. Of course you might want to make the link a block and alter the dt CSS so the link fills the entire area. Shoot me an email if you can’t get it worked out.

Michael on 07 Jun 2008 at 10:22 am

Thank you so much!!

Sergio A on 07 Jun 2008 at 11:08 pm

@Michael,

What’s the status of the sub-sub menu?
I’m still waiting at the release.

joey on 09 Jun 2008 at 3:19 pm

@joey - Had hoped to release last night but have run into an ugly IE6 issue as usual. Will continue this evening if I have some time.

Michael on 09 Jun 2008 at 3:25 pm

Awesome! Thanks for sharing this. One question: How can I change it so that the menu background fades to only, say, 75% opacity?

Thanks again!

Bill on 09 Jun 2008 at 8:09 pm

Michael, Love the menu! I was thinking of doing something similar using script.aculo.us, but then I came across your menu. It looks good and it’s much more lightweight than the script.aculo.us version would be, I think. Anyway, I really need an additional level for the site I’m working on (you know, the sub-sub menu everyone is asking for). What is your eta on having a working version of that? Thanks so much!

Erik on 10 Jun 2008 at 11:26 am

@Erik - I would like to say this evening but I can’t say for sure. All I lack is a stubborn IE issue I have to work around. I will shoot you and others an email when it is active.

Michael on 10 Jun 2008 at 3:11 pm

Hello Michael, what a splendid menu! But I have a small problem.
When i use your menu, and say use 5 menus in a row beside each other, and i want one button to have no dropdown-menu but only a link, how do i inplement this in the html? or should i use, for this single button, a mouse-over script. Thanks, John

John Devriesch on 11 Jun 2008 at 3:59 am

@John - It really depends on your situation. You could just use the same style in the CSS for the dt tag on a class for your static links and then simple add in a link where you need it. There are a few ways to tackle it. Shoot me an email if you need help.

Michael on 11 Jun 2008 at 8:06 am

Hi Michael, The drop down looks great. Thanks for sharing. I just wondered if you have created or seen anyone use unordered lists layout for the drop down trigger instead of definition lists? I’m hoping to incorporate this into a site using the modX CMS.

Andy on 11 Jun 2008 at 10:44 am

@Andy - Originally the menu was using block links and unordered lists so it is definitely possible with little modification. Shoot me an email and I can help you work through it.

Michael on 11 Jun 2008 at 12:39 pm

@Michael,

What do I wrong to make a link in the head section:
My dropdown.html file:
[code]
<dl class=”dropdown”>
<dt id=”1-ddheader” onmouseover=”ddMenu(’1′,1)” onmouseout=”ddMenu(’1′,-1)”>
<a href=”/index.htm”><font color=”#232323″>Algemeen</font></a></dt>
<dd id=”1-ddcontent” onmouseover=”cancelHide(’1′)” onmouseout=”ddMenu(’1′,-1)”>
<ul>
<li><a href=”/index.htm”><font color=”#232323″>Home</font></a></li>
<li><a href=”/contact.htm”><font color=”#232323″>Contact</font></a></li>
<li><a href=”/forum/”><font color=”#232323″>Forum</font></a></li>
</ul>
</dd>
</dl>

<dl class=”dropdown”>
<dt id=”2-ddheader” onmouseover=”ddMenu(’2′,1)” onmouseout=”ddMenu(’2′,-1)”>
<font color=”#232323″>Gratis software</font></dt>
<dd id=”2-ddcontent” onmouseover=”cancelHide(’2′)” onmouseout=”ddMenu(’2′,-1)”>
<ul>
<li><a href=”/Gratis%20software/index.htm”><font color=”#232323″>Gratis
software</font></a></li>
</ul>
</dd>
</dl>

<dl class=”dropdown”>
<dt id=”3-ddheader” onmouseover=”ddMenu(’3′,1)” onmouseout=”ddMenu(’3′,-1)”>
<font color=”#232323″>Tools</font></dt>
<dd id=”3-ddcontent” onmouseover=”cancelHide(’3′)” onmouseout=”ddMenu(’3′,-1)”>
<ul>
<li><a href=”/Tools/Radio/index.htm”><font color=”#232323″>Online
radio</font></a></li>
</ul>
</dd>
</dl>

<div style=”clear:both” />
[/code]

And my Stylesheet .css file:
[code]
body {margin:25px; font:12px Verdana, Arial, Helvetica;}
* {padding:0; margin:0}
.dropdown {float:left; padding-right:5px}
.dropdown dt {width:188px; border:2px solid #9ac1c9; padding:8px; font-weight:bold; cursor:pointer; background:url(images/menu/header.gif)}
.dropdown dt:hover {background:url(images/menu/header_over.gif)}
.dropdown dd {position:absolute; overflow:hidden; width:208px; display:none; background:#fff; z-index:200; opacity:0}
.dropdown ul {width:204px; border:2px solid #9ac1c9; list-style:none; border-top:none}
.dropdown li {display:inline}
.dropdown a, .dropdown a:active, .dropdown a:visited {display:block; padding:5px; color:#333; text-decoration:none; background:#eaf0f2; width:194px}
.dropdown a:hover {background:#d9e1e4; color:#000}
.dropdown .underline {border-bottom:1px solid #b9d6dc}
[/code]

Joey; The Netherlands

Joey on 12 Jun 2008 at 5:52 am

@Joey - It will be a lot easier for me to look at if you can send me a link to your page… michael@leigeber.com

Michael on 12 Jun 2008 at 8:18 am

@Michael

I have send a mail to you. With my websiteadress and information.

Joey: The Netherlands

Joey on 13 Jun 2008 at 9:47 am

Thank you for this wonderfull dropdown menu. It really is the best of its kind !

Blix on 13 Jun 2008 at 7:46 pm

Very good, thanks a lot

Pradeep on 14 Jun 2008 at 1:17 am

Thank you so much Michael for leaving me your reply. And i’m terribly sorry for this late reply. You are just that one-of-the-kind nicest person around.

Lawrence on 16 Jun 2008 at 2:45 pm

First things first, this nav is outstanding, and it makes idiots like me look like a wizard. for that, i think you greatly. On to the point…

This may be somewhat contrary to the concept of a CSS nav, but i have… unique clients that require the use of an image as the main nav link, with the animated flyout. I was wondering if there’s a decent way to do this instead of using a css text based top nav link?

JB on 17 Jun 2008 at 12:32 am

Hey, I love this script:) Its great.

Could you please tell me how i would go about making sub menus for this, like, having a dropdown menu within a drop down menu. Thanks.

COdie on 17 Jun 2008 at 5:34 am

@JB - Sure, you could just remove the padding from the dt and add in an image or use CSS background images through the use of different classes for each. Shoot me an email if you get hung up on anything.

@Codie - I have been working on this and will hopefulyl get some time to look at it again. http://sandbox.leigeber.com/multilevel/

There are a few tricky issues, particularly with IE.

Michael on 17 Jun 2008 at 8:18 am

Hello,

I have finished the headers link. (With help from Michael)

The stylesheet file (.css) should you edit to:

——————————————————————
body {
margin:25px;
font:12px Verdana, Arial, Helvetica;
}

* {
padding:0;
margin:0
}

.dropdown {
float:left;
padding-right:5px
}

.dropdown dt {
width:188px;
border:2px solid #9ac1c9;
padding:8px;
font-weight:bold;
cursor:pointer;
background:url(images/menu/header.gif)
}

.dropdown dt:hover {
background:url(images/menu/header_over.gif)
}

.dropdown dd {
position:absolute;
overflow:hidden;
width:208px;
display:none;
background:#fff;
z-index:200;
opacity:0
}

.dropdown ul {
width:204px;
border:2px solid #9ac1c9;
list-style:none;
border-top:none
}

.dropdown li {
display:inline;
width:204px;
}

.dropdown ul a:active, .dropdown ul a:visited {
display:block;
padding:5px;
color:#333;
text-decoration:none;
background:#eaf0f2;
width:100%
}

.dropdown li a {
display:block;
padding:5px;
color:#333;
text-decoration:none;
background:#eaf0f2;
width:100%
}

.dropdown dt a {
display:block;
color:#333;
text-decoration:none;
background:transparant;
width:100%
}

.dropdown dt a:active, .dropdown dt a:visited {
display:block;
padding:0px;
color:#333;
text-decoration:none;
width:100%;
background:transparant;
}

.dropdown li a:hover {
background:#d9e1e4;
color:#000
}

.dropdown .underline {
border-bottom:1px solid #b9d6dc
}
————————————————————————-

If you would add a headers link you should do the follow:

1. Search the <DT> rule into your file:
<dt id=”1-ddheader” onmouseover=”ddMenu(’1′,1)” onmouseout=”ddMenu(’1′,-1)”>

2. After this rule, before the </dt>, you should past the follow:
<a href=”LINK.html”><font color=”#232323″>NAME OF THE LINK</font></a></dt>

3. If you do it just you will finally see this:
<dt id=”1-ddheader” onmouseover=”ddMenu(’1′,1)” onmouseout=”ddMenu(’1′,-1)”>
<a href=”LINK.htm”><font color=”#232323″>NAME OF THE LINK</font></a></dt>
<dd id=”1-ddcontent” onmouseover=”cancelHide(’1′)” onmouseout=”ddMenu(’1′,-1)”>
I have test it with internet explorer 6 and 7 and with firefox 2, and it works great.

Do you have any problems?? Tell it me or someone.

Joey on 17 Jun 2008 at 8:31 am

@Michael, that is exactly what Im looking for, could you post the source code for that, sorry im still noob, only started about a month ago. Thanks.

COdie on 17 Jun 2008 at 8:42 pm

@Michael, Looked at your sandbox version of the multilevel nav. I took a quick look in IE6 and didn’t notice any immediate issues. Maybe I didn’t look hard enough. Can you explain the issues you are seeing and trying to resolve?

Again, thanks for all your work on this menu and your willingness to share. You have really done an amazing job!

Erik on 18 Jun 2008 at 7:51 am

@Michael, Actually I just modified your code to fit my needs and I see more of a problem with my multilevel version in IE6 than I see with yours. I’m not sure where I went wrong… Have a look if you’d like.

http://projecto3.com/clients/covenant_dropdown/index.html

Erik on 18 Jun 2008 at 8:04 am

@Codiue and Erik - I will try and wrap it up today. I fixed another bug yesterday and have 2 left. I will add a new post then.

@Erik - As for your issue, looks like an IE only thing. I really need to spend my time wrapping this up and then after I release the final code if you are still having problems I will take a look.

Michael on 18 Jun 2008 at 8:27 am

excellent code!
question: is there a way to have the dt element (’Dropdown One’ in the demo) stay ‘active’ with the hot color (darker color in the demo) when you mouse over the dropdown items instead of switching back?

mothra9999 on 20 Jun 2008 at 12:15 pm

@mothra9999 - It would have to be done with the JavaScript, it should only be two lines of code. One in the ddMenu that appends another class to the header and then one in the ddCollapse function that removes that classname. Shoot me an email if you can’t get it figured out.

Michael on 20 Jun 2008 at 3:45 pm

Thanks for the great example! Is there any way to make it so the drop down opens and closes on click instead of on mouseover?
I got it to open on click by changing the mouseover to this: onclick=”ddMenu(’one’,1)” which works. Though is there a way to get it to close by clicking on the main menu tab again?
Thanks!

Eric on 21 Jun 2008 at 2:23 pm

@Eric - It can definitely be done. I am a little tied up the next day or so but shoot me an email if you can’t get it worked out and I will do what I can to help.

Michael on 22 Jun 2008 at 9:51 am

Michael - Great script. Very clean and straightforward. Excellent job as far as I can tell.

I’ve been playing with the multilevel and noticed if you hold your mouse over a sublink (IE7) and just let it hover there for 15 seconds or so, the page length starts to buildup and te scroll bar on the page keeps increasing.

Not sure if you were aware of that. Great job though!

Chris on 23 Jun 2008 at 4:30 pm

@Chris - Thanks, yea I am aware, it is one of the couple remaining issues with the script. I just haven’t had any time lately to wrap it up.

Michael on 24 Jun 2008 at 8:35 am

Michael - thank you very much for this script! This is the coolest dropdown menu I’ve found. Really, really great.
However, I am having a problem with the menus flashing and displaying behind a .swf - in IE and firefox. I’ve added wmode=”transparent” to my object and embed tags for the swf, but still no joy. Have you seen this before? Any suggestions?

haymaker on 27 Jun 2008 at 1:52 pm

@haymaker - Email me a link and I will look into it. If you have the flash embedded correctly it should not be an issue.

Michael on 29 Jun 2008 at 6:25 pm

Awesome, this solves my problem with my non-flash commitment. Thanks a lot!

Louis on 30 Jun 2008 at 5:12 am

Great job. Waiting to see the multilevel one.

Jorge on 30 Jun 2008 at 12:14 pm

Great job. I do have a problem however, I’m using this drop-down bar for a wiki, and it tends to render wrong (submenus are shifted towards the right). Any suggestion? I myself am not such a CSS/JS expert…

Antoine on 01 Jul 2008 at 10:48 am

@Antoine - Have you checked to be sure that your CSS is in place and that none of your existing CSS shares the same class/id names as the dropdown styles? Shoot me an email if you don’t see a conflict and I will dig into it.

Michael on 02 Jul 2008 at 8:01 am

Michael, any luck with the problem that haymaker was having? I’m having a nightmare with Firefox 2 on Mac when the menu appears directly above a Flash object. I’ve tried everything I can in terms of z-index, wmode=transparent (and opaque), etc. etc., and am having no joy.

I think my last option must be to just detect for FF2 and show an image instead of Flash?

Any help would be much appreciated.

Ben on 03 Jul 2008 at 1:53 am

Oops and I forgot to say what my problem even was! Basically, it’s to do with FF2’s hatred/refusal of the CSS ‘opacity’ property when combined with Flash (on Mac at least). As soon as the menu slides down (and thus the bits with opacity on them touch the Flash object), the Flash disappears completely. I’ve found some info about this here:

http://jakeo.org/blog/2007/03/16/css-opacity-and-flash-transparency-in-mac-firefox/

But have been unable to apply his fix to this menu.

Ben on 03 Jul 2008 at 1:56 am

Hi Michael, its really good work. Do u have any idea how to use menu source as xml like ajax switch menu http://www.getelementbyid.com/scripts/doc/AjaxSwitchMenu.html

Thanks alot

veeru on 04 Jul 2008 at 4:16 am

@Ben - I was not aware that FF had an issue like that. Unfortunately I do not have a mac to test on so getting that resolved will be difficult. If I can get hold of a mac I will check it out else let me know if you ever get it resolved. Thanks.

@veeru - Sure, it wouldn’t be hard to parse XML for the menu structure. I will add JavaScript XML parsing to my post todo list.

Michael on 04 Jul 2008 at 8:19 am

Agreeing with everyone.. GREAT script. Two quick questions… 1. Can this work together with your other script “Sliding JS Menu Highlight” http://www.leigeber.com/2008/05/sliding-javascript-menu-highlight-1kb/

and 2. Can this work without using a DL and just use a div and ul, li combination (as that’s the way I have the Sliding JS Menu script working)… Let me know. - Thanks again!

fritzd on 04 Jul 2008 at 7:17 pm

Thanks for replying Mike. My solution was to just place the Flash object in a div with a background image that looks identical to the Flash (just without animation), so that when the Flash does disappear, the FF2 Mac users will hardly notice.

The CSS-transparency-freaking-out-with-Flash issue has been fixed in Firefox 3 so there’s no need to worry about it really!

Ben on 05 Jul 2008 at 12:33 am

Dear Michael

Plz let me know that when ur trying to give support for xml datasource. Thanks alot
Veeru

veeru on 05 Jul 2008 at 10:54 am

@fridtz - Sure you could combine the two scripts, should not be a problem. It would also be a pretty easy change to use simple unordered lists Shoot me an email if you need help.

@Ben - Glad it got resolved.

Michael on 06 Jul 2008 at 2:02 pm

Nice menu. ;)

i have been trying to center the menu but, whatever i do, it still pushes the dropdown to the right.
is there a way to fix that?

mahyar on 07 Jul 2008 at 10:29 am

Very nice menu.

I have been waiting for the multilevel menu. Can you tell me when would that be live.

Thanks

Bharat on 10 Jul 2008 at 7:05 am

Hi,

I tried to use your Sliding JavaScript Menu Highlight script with this one. However, I couldn’t get both of them work at the same time.

Any ideas?

http://www.taksimapartments.com/en/

Dropdown menu is under apartments.

Thanks,

Gercek Karakus on 11 Jul 2008 at 7:00 am

You can contact me from gercekkATgmailDOTcom

Gercek Karakus on 11 Jul 2008 at 7:01 am

[...] 1: Get this JavaScript menu (.js) and put it into [...]

jsedlak » Blog Archive » Theming SharePoint (5 of Infinite) on 11 Jul 2008 at 11:32 am

Hi ! this script is awesome ! i try to embedd it into a Wordpress blog, but i don’t know exactly how to do it… i uploaded the .js and the css to the theme’s folder, and then past in the header.php the html code … but i’m afraid i need to write something in php language … ? well, any tip will be welcome !

ignacio on 11 Jul 2008 at 12:50 pm

@ignacio - It depends on what links you will including in the dropdown. Shoot me an email with the details/link and I will point you in the right direction.

Michael on 11 Jul 2008 at 5:50 pm

Hi! Excellent script, but have a question if you have the time to answer. I used the src code and scripts for the sub-sub menu, got it working on it’s own. As soon as I use it as an include file in .asp it stops working. Any suggestions? I had used your sub menu dropdown and it was great, then the client needed sub-sub menu dropdown, so had to change and now can’t get it working when it is included.

Lauren on 17 Jul 2008 at 7:42 am

@Lauren - That doesn’t make much sense unless there is a JavaScript conflict of some sort. There is nothing specific to ASP that should cause a problem. Shoot me an email with a link if the site is external and I will dig into it.

Michael on 17 Jul 2008 at 5:50 pm

Thanks a lot for this nice looking piece of work, Michael… I played around with this script today and noticed that after the menu slides down and up again, there’s a small 4 px wide area underneath it… you can check this easily if you set a black background or turn opacity to 1 and take away c.style.opacity = currh / c.maxh; and // c.style.filter = ‘alpha(opacity=’ + (currh * 100 / c.maxh) + ‘)’;… i checked c.style.height = currh + (dist * d) + ‘px’ for this and actually this variable never drops below 4px… i’ll keep on working it, but maybe you have an idea why that is and can help me out… hope to hear from you :) <- using FF3/SeaMonkey

Thallah on 19 Jul 2008 at 12:39 pm

ok, i am a little step further with my problem (above post): it seems like there is some issue with DDSPEED. when i set DDSPEED to < 2 everything works fine but any value above 2 will lead to some (not wanted) space below the menu bar, the size of this area changes with the value of DDSPEED (a value of DDSPEED = 100 will leave an area the size of Navigation Item 1 and 2 for example)… a value of DDSPEED = 2 and DDTIMER = 35 will lead to an acceptable result. i still would be interested in your opinion if there is any (other) way to fix this, otherwise a comment in the .js file might be helpful.

Thallah on 19 Jul 2008 at 1:40 pm
Trackback URI | Comments RSS

Leave a Reply

Subscribe to RSS Feed
Powered by FeedBurner
Recent Links
Tag Cloud