Created
August 9, 2012 00:10
-
-
Save ando19721226/3299880 to your computer and use it in GitHub Desktop.
addListener
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var addListener = (function (window) { | |
if (window.addEventListener) { | |
return function (el, type, fn) { | |
el.addEventListener(type, fn, false); | |
}; | |
} | |
if (window.attachEvent) { | |
return function (el, type, fn) { | |
var f = function () { | |
fn.call(el, window.event); | |
}; | |
el.attachEvent('on' + type, f); | |
}; | |
} | |
return function (el, type, fn) { | |
el['on' + type] = fn; | |
}; | |
}(window)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://blog.livedoor.jp/dankogai/archives/50816979.html