Posted By

Roshambo on 07/23/06


Tagged

events listener addeventlistener attachevent


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

mate
meth
Hirmine
jamesming
danvan1986
wirenaught


Add Event Listener


 / Published in: JavaScript
 

Cross-browser implementation of element.addEventListener(). Simple, straightforward, and functional.

Useage: addListener(window, 'load', myFunction);

  1. // Cross-browser implementation of element.addEventListener()
  2. function addListener(element, type, expression, bubbling)
  3. {
  4. bubbling = bubbling || false;
  5.  
  6. if(window.addEventListener) { // Standard
  7. element.addEventListener(type, expression, bubbling);
  8. return true;
  9. } else if(window.attachEvent) { // IE
  10. element.attachEvent('on' + type, expression);
  11. return true;
  12. } else return false;
  13. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: bingbong on September 20, 2007

I need some code like this to listener when exactly form submit written by javascript. Somebody help me in urgent please! Thank you for your attention!!!

Posted By: on January 11, 2019

download best software to android root use app kingo or 360 for pc mac ios windows 10 8 1 7 xp computer community

You need to login to post a comment.