View Full Version : Resolved How do you change mouseover to onclick?

12-14-2008, 06:03 AM
1) Script Title: All Levels Navigational Menu (v1.5)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/ddlevelsmenu/

3) Describe problem:
Can anyone tell me how I can change the mouse over event to an onclick event with the top level menu? I am experimenting with using a button (with mouseover effects) for the user to click on the button to open the menu "onclicK".
If you can give me any tips on how to replace the background text link panel with an image of a button as well, then that would be great.

I've so far tried searching the forums but cannot seem to come up with an answer.

!!* If anyone else is interested in changing the script for clicking the menu instead of mouseover (This is not including any mods to have an image instead of the normal menu.)
I have uploaded a new script (provided by DDAdmin) for this to work correctly.:D

12-14-2008, 10:54 AM
Replace your JavaScript file with this one:

You also have to make sure that the buttons with submenus do not link to another page.

I'm afraid I don't understand what your second request is.

12-14-2008, 02:27 PM
Thanks Snookerman,
I uploaded the version you gave me and the to see that it works gave me great joy, however, there is only one problem and that is when I click on the image of the button; the menu opens but closes straight away again!
Just wondering if you know what might be causing this?
Don't worry about the second part of my original question as I found a way to set the image of the button in place of the original 'interface' that the script produces on the page.
I really appreciate your help with this script - I didn't think I was going to have much luck other than a difficult road of trying to study up on Javascript coding.
Again, if you can help me with an answer to the menu not staying open, then that would be great.
I also just noticed that there are some other problems with the menu not opening properly at all - ( a rectangular vertical section opens up uncovering only part of the submenus ). I'm not sure if this is because of the way I have attached the image of the button?
The URL is: (no longer here as the page is no longer active) if you want to check the source code to see what I might be doing wrong.
Thanks. :):confused:

12-14-2008, 03:13 PM
For the links that you click change this href="" to this href="#".

12-15-2008, 02:24 AM
Thanks again for your help Snookerman, I did what you said and it resolved the problem but only partially.
The problem seems to be with the image itself. The text links work to expand the vertical menu and keep it open, however when I click on the image of the button, the menu expands but will stay open only sometimes.
The problem seems intermittent and will not work most times that I test the button.
As soon as the left mouse click is released the menu will still close.

I tried removing the mouse rollover effect from the button image, thinking that maybe there was interference with the java script but it still made no difference to the problem.

I was wondering if there may be some kind of adjustment that can be made to the 'ddlevelsmenu' file in order to solve the problem with using this (interactive) image?

I'm sorry to take your time with this but really do appreciate the help that you have already given to me and any help that you may still be able to give in this matter.

Thanks again.:):confused:

12-15-2008, 09:43 AM
Thanks for everything,
I spied a hidden line of text in the java script file that read:

//hide drop down ul if mouse moves out of menu bar item but not into drop down ul itself

This gave me a clue about the width of the sidebar menu.

Solution: Edit the line of code in the ddlevelsmenu-sidebar stylesheet:

width: 210px; /*width of side bar menu*/

to the width of my (button) image

Problem solved!!:)

12-15-2008, 01:03 PM
You're welcome and I'm glad it worked out for you. Remember to go to your first post in this thread, edit, go advanced and add the Resolved prefix to the thread title.

01-06-2011, 11:32 PM
Sorry to drag up old post - but I also need this - mobile phone browsers (Android at least) do not trigger the mouseover event, so cannot use the menus. The patched V1.5 seems to work fine, but is there any benefit in applying the fix to V2.2 - or is it possible to make onclick configurable, or perhaps even in addition to mouseover?

01-07-2011, 08:33 PM
I am using v2.2 of the All Levels Navigational Menu on a website, but I have this issue that when users "click" on the main menu bar the drop-down sub menu closes. This behaviour upsets the users as they would expect either a page to open (which I do not offer as they are all set href="#"), or the drop-down sub menu to at least stay open.

I have looked at the code in ddlevelsmenu.js but it is quite complex and would like some expert advice on what to change. I would like the drop-down to appear "onclick" in addition to "mouseover" for the main menu (top bar) items.

01-08-2011, 01:26 PM
Please start a new thread for a new question.