javascript - event object not defined only with Firefox (IE and Chrome works) -


this question has answer here:

<a class="lnk" href="#" onclick="showitem();">     <span data-id="27">test</span> </a>  function showitem() {     var itid = event.target.dataset.id;     alert(itid); } 

if try this jsfiddle code can see ie (11) , chrome event object correctly evaluated, firefox (32.0) error (referenceerror : event not defined)

it's bug of firefox or different event object lifecycle in ie , chrome ? since in ie , chrome it's working think it's problem. workaround ?

p.s: in jsfiddle, firefox, code selection still having problem (after run cannot select code.

you should pass event argument function:

<a class="lnk" href="#" onclick="showitem(event);">     <span data-id="27">test</span> </a>  function showitem(e) {     e = e || window.event;     var itid = e.target.dataset.id;     alert(itid); } 

accessing global variable ie feature chrome copied, don't think it's standard javascript.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -