Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 16th, 2007, 05:12 PM
tal tal is offline
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default OnMouseOver & OnMouseOut

Hi,
My page has a div with 2 event handlers: "onmouseover" and "onmouseout". However, the div has several inner items, so when the mouse goes over one of them, this triggers the div's "onmouseout".

I need this event to trigger only when the mouse completely leaves the div.. (when the mouse goes over an inner object, it is still over the div, and i can't prevent the "onmouseout" event.. :()

Help anyone

 
Old July 16th, 2007, 11:52 PM
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi tal

You can use "onmouseleave" event instead of "onmouseout".
"mouseleave" event would be fired just when mouse is completely out of your element.

Ehsan Zaery Moghaddam
 
Old July 17th, 2007, 06:47 AM
tal tal is offline
Authorized User
 
Join Date: Apr 2007
Location: , , .
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Default


But no
onmouseleave is an IE-only event..
What needed here is an implementation of this, but i'm starting to think this is not possible :(

Quote:
quote:Originally posted by zaerymoghaddam
 Hi tal

You can use "" event instead of "onmouseout".
"mouseleave" event would be fired just when mouse is completely out of your element.

Ehsan Zaery Moghaddam



 
Old July 17th, 2007, 09:16 AM
Authorized User
 
Join Date: Jun 2007
Location: Tehran, Tehran, Iran.
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi again

You can watch location of mouse in your "onmouseout" and check whether it's exact position is inside your div element or not?

(of course if you have an exact width and height of your div element)

Ehsan Zaery Moghaddam
 
Old July 19th, 2007, 02:29 PM
Friend of Wrox
Points: 1,749, Level: 16
Points: 1,749, Level: 16 Points: 1,749, Level: 16 Points: 1,749, Level: 16
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2007
Location: San Diego, CA, USA.
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts
Default

You do have another option, but it's not a step-by-step.

There are "some" times that JS considers mousing over a child element to be a mouseout, there are "others" that it doesn't. I was never able to find a satisfactory to patch the "mouseout" behavior. However, when I programmed what I wanted to do in a different way, it worked fine.

If it's helpful to you, you can check out my beta website for details of my specific situation.

http://beta.earthchronicle.com/ECBet...Detection.aspx

Steps 5,6,&7 are where I developed the code that ran away from child elements. Step 8 was where I took a different approach. That's how I got mine to work.

-------------------------

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.




Similar Threads
Thread Thread Starter Forum Replies Last Post
onmouseover sstuber BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 April 29th, 2008 12:30 PM
Safari does not trigger onmouseout albeik BOOK: Professional JavaScript for Web Developers ISBN: 978-0-7645-7908-0 2 August 14th, 2006 07:34 PM
onmouseover gilgalbiblewheel HTML Code Clinic 4 February 4th, 2005 08:05 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
OnMouseOut for definitions of names. Possible? gilgalbiblewheel Java Databases 1 September 18th, 2004 02:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.