suppose I have some javascript which says:
window.onunload=some_jsfunction();
how can I add another function to this handler? something like this:
window.onunload=some_jsfunction() + another_jsfunction();
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.
The first and foremost way:
addEventListener:Another way is too create a new event handler with a call to the old handler from it, then overwrite the old handler. I can imagine a situation where it could be useful, but not with DOM events:
The most advanced way is creating your own observer on top of the DOM’s observer (this is what frameworks like Mootools do internally). It can be helpful in the long term; for example, to add event namespaces.