Jump to content

Addevent()


abdelelbouhy

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...