[Javascript] Event question and finding pointer position at event

Bill Moseley moseley at hank.org
Tue Mar 28 22:21:06 CST 2006


Sorry for dragging this out...

On Tue, Mar 28, 2006 at 02:55:00PM -0500, Steve Clay wrote:
> Here was the page I should have referred to:
> http://www.quirksmode.org/js/events_mouse.html#mouseover

That's interesting.

The method used there takes the element where the event came from and
walks the DOM outward.  If you find the node where the event happened
then you know the event happened inside.  If you come across "body"
then you know you are leaving the menu layer (i.e. the event was not
inside the layer):

    /* Now move up looking to see if current element is found */
    while (reltg && reltg != tg && reltg.nodeName != 'BODY') {
        debug('looking at node <' + reltg.nodeName + '>' );
        reltg = reltg.parentNode;
    }

As things turn out, I'm not exactly seeing that.

The first node I see (the relatedTarget) is "html", so "BODY" is never
passed.  I don't understand why it's not working like I expect.  But
testing for a null reltg (in addition to testing for "BODY") seems to
work.

    http://hank.org/demos/menu3.html

-- 
Bill Moseley
moseley at hank.org




More information about the Javascript mailing list