Jump to content

Addevent()


abdelelbouhy
 Share

Recommended Posts

function addEvent(node, type, listener){ if(!isCompatible()){ return false;} if(!(node = $(node))){ return false;} if(node.addEventListener){ //w3c method node.addEventListener(type, listener, false); return true; }else if(node.attachEvent){ //MSIE method node['e'+type+listener] = listener; node[type+listener] = function(){ node['e'+type+listener](window.event); } node.attachEvent('on'+type, node[type+listener]); return true; } return false; };hello guys anyone please can explain this line for menode['e'+type+listener] = listener; node[type+listener] = function(){ node['e'+type+listener](window.event); }why there is the letter 'e' in node['e'+type+listener] and what realy he want to say in this line is it = (node.e.type.listener)

Link to comment
Share on other sites

It actually doesn't make sense to me. Where did you get this function? Besides, there's no "isCompatible()" function either.This is what the function should look like:

function addEvent(node, type, listener){  if(node.addEventListener){	//w3c method	node.addEventListener(type, listener, false);	return true;  }else if(node.attachEvent){	//MSIE method	node.attachEvent('on'+type, node[type+listener]);	return true;  } else {	node['on'+type] = listener;  }return false;};

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...