SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    runat="server" Golgotha's Avatar
    Join Date
    Nov 2001
    Location
    Colorado
    Posts
    2,085
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Throwing an error...

    I'm throwing the below error:

    targ has no properties
    while (targ.parentNode) {

    The full code is below:

    Code JavaScript:
    function hideTip(e){
        //http://www.quirksmode.org/js/events_mouse.html
        //http://www.quirksmode.org/js/events_properties.html
        var targ;
        if (!e) var e = window.event;
        if (e.target) targ = e.target;
        else if (e.srcElement) targ = e.srcElement;
        if (targ.nodeType == 3) // defeat Safari bug
            targ = targ.parentNode;
     
     
        var targ = e.relatedTarget || e.toElement;
        //mka look at below
    while (targ.parentNode) {
            if (targ.id === 'commentTipPopUp')
            { 
                return;
            } else {
                targ = targ.parentNode;
            }
          }
     
        commentTipPopUp.style.display ='none';
    }

    Help thanks...

  2. #2
    SitePoint Guru
    Join Date
    May 2004
    Location
    santa rosa, ca
    Posts
    969
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you see if you put console.log(e); at the top of that function?
    nondenominational, noncommercial, nonprofit,
    listener-supported, 24-hour, Christian ministry:
    Listen Live Online

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,215
    Mentioned
    153 Post(s)
    Tagged
    0 Thread(s)
    Hey Mark (again),

    I figured out your error using the technique described by 'SantaRosaDesign'. In short, I put console.log(e) and console.log(targ) in the hideTip function.

    What I found is if you move the mouse over and out of the link quickly (extremely quick), the clientY property of e will be negative (ie: -6, -12, whatever the distance the mouse's Y coordinate is outside of the element). In short, you should put a null check on the targ variable before the while loop to avoid that situation.

    The same likely could happen with the clientX property too, but that would be MUCH harder to do.

    Enjoy!
    Matt


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
  •