Possible Duplicate:
window.event.srcElement doesn’t work for firefox?
I made a web page that works fine with Chrome, but doesn’t with Firefox.
Here’s the code:
function set_email_params(e){
if(!e)
e=window.Event; //window.event appeared to be "undefined" so I had to use Event
alert(e.target); //shows "undefined"
alert(e.target.src);
if(e.target.src.indexOf("unchecked")>-1)
e.target.src='images/small_radio_checked.png';
else
e.target.src='images/small_radio_unchecked.png';
}
Here’s how the function is called:
<img onclick="set_email_params()" src="images/small_radio_unchecked.png" style="float:left;"/>
This code works perfectly on Chrome.
Please help me.
You’re not passing the
eventobject in the handler.In a standards compliant browser, the event handler will end up looking something like this:
While in older IE it’ll look more like this:
So either way, the event object will be passed on.