javascript - Undefined ParentNode DOM error onmouseout -


how's it,

[here small page illustrating problem] (problem appears in firefox)

so have function onmouseout="regress(event, this)" tests if mouse actually got outside current element , of it's children. (more details on why did , matter). if mouse outside, want stop animation on button , reset timer (which did). , works.

only doesn't. in firefox (tested v5.0) is. dom related error. parentnode of element triggered function "" , parent of "undefined" , error , code explodes.

here's baffling part: error occurs when mouse goes off button area. there's case when onmouseout event gets triggered (for avoidance of i'm using function). onmouseout off child of button child of button. in case, parentnode works fine, going buttonchild button buttonparent blabla body , stops.

my question is, why undefined error appear in 1 case , doesn't in other. mind there no errors in chrome or ie9. how can fix it?

this baffles me. thank help.

i baffled.

also here javascript function:

function regress(evt, x){     //if (!e && window.event)      if (window.event)          var e = window.event;     else         var e = evt; //if got here, you're using firefox     var reltg = (e.relatedtarget) ? e.relatedtarget : e.toelement;      while (reltg.tagname != 'body')     {            //alert(reltg.id+" == " + x.id);         if (reltg.id == x.id)         {              return;         }         reltg = reltg.parentnode;         //alert(reltg.tagname);     }     // i'm on true mouseout, stuff here:     $("#"+x.id+"thickparent").stop(true, false);     $("#"+x.id+"thickparent").width(0);      canstartagain=true;      stopinterval = true;     timervalue = 1.50;     $("#"+x.id+"timer").html("");     //thanks to: http://www.webmasterworld.com/javascript/3752159.htm } 

uncomment //alert(reltg.id+" == " + x.id); see when onmouseout got triggered , element reltg.parentnode on @ time.

i got same problem few months ago. notice exiting top side error don't happen. reason "body" tag narrowed fit the inner div , extended top , when moving botton(or leff, or right) ff triggers event related target pointing "html" tag , in loop stop condition tag being "body" one. parent of "html" tag document , document's parent null , error throw when try access tagname property of null. achieve expected result must change stop condition while (reltg.tagname != 'html') or error resilient while (reltg && (reltg.tagname != 'body')).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -