日期:2014-05-16 浏览次数:20304 次
var on = function(node, eventType, param, callback) { node = typeof node === 'string' ? document.getElementById(node) : node; if(node.addEventListener){ node.addEventListener(eventType, function(event){ event.data = param; callback.call(node, event); }, false); }else{ node.attachEvent('on' + eventType, function(){ event.data = param; callback.call(node, event); }); } }
------解决方案--------------------
on : function(node, eventType, param, scope, callback) {
node = typeof node === 'string' ? document.getElementById(node) : node;
function innerCallback()
{
var scope = scope || window;
var param = param;
callback.apply(scope,param);
}
if (document.all)
node.attachEvent('on' + eventType, innerCallback);
else
node.addEventListener(eventType, function(event){
innerCallback(event);
}, false);
}