function doSomething(e) {
var targ;
if (!e) var e = window.event; //<<<< what does it do this check?
if (e.target) targ = e.target;
}
Why do we need to check this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This adds compatibility with older (Internet Explorer?) browsers that didn’t support passing the
eventobject to handlers but instead defined them on the window object.Also the
varis not needed invar e = window.eventbecause it’s already declared (parameter).It can also be written as
e = e || window.event;