SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    onmouseout problem with menu

    Hey all,

    I've made a JavaScript menu system for a client, however he wants the menus to disappear when the mouse moves away from the menu.

    I have an onmouseout even handler in the <div> tag, however the menu disappears when the mouse is moved away from a link on the menu, even if it stays over the DIV.

    What is the best way to stop this from happening?

    Thanks

    -Sam
    Sam Hastings

  2. #2
    SitePoint Addict xDev's Avatar
    Join Date
    Jul 2003
    Location
    Moncton, New Brunswick, Canada
    Posts
    247
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    A really quick fix would be to take out the onmouseout on the submenu and put in an onmouseover (calling the hide method) in any content block that surrounds it.

    -xDev

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice idea

    I'll give it a go and let you know how I got on.

    Thanks!

    -Sam
    Sam Hastings

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've had better luck not using mouseover/mouseout, and only using mousemove. But there are many different ways

    In more stds-compliant browsers you will get mouseover/mouseout/mousemove events on text nodes which then bubble up to the element in question. In your event listener check the event's target->nodeType property. Another technique is to create a unique property (for example: 'isMenuBox') on the element (perhaps the menu box itself) and iterate up the parent chain of the event's target.

    xDev also has an interesting idea.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •