Skip to content

Instantly share code, notes, and snippets.

View gaomeng1900's full-sized avatar
🎩
mua

Simon gaomeng1900

🎩
mua
View GitHub Profile
@gaomeng1900
gaomeng1900 / addEventListener-polyfill.js
Created April 22, 2016 17:13 — forked from eirikbacker/addEventListener-polyfill.js
addEventListener polyfill for IE6+
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence
(function(win, doc){
if(win.addEventListener)return; //No need to polyfill
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}}
function addEvent(on, fn, self){
return (self = this).attachEvent('on' + on, function(e){
var e = e || win.event;
e.preventDefault = e.preventDefault || function(){e.returnValue = false}
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true}