Created
August 16, 2012 22:05
-
-
Save jameswomack/3374021 to your computer and use it in GitHub Desktop.
Getting an array of all events possible on winow and use to remove all events from an object
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
window.__defineGetter__('events',function(){ | |
var _events = []; | |
for (var k in window) { | |
if(k.match(/^on/)){ | |
_events.push(k) | |
} | |
}; | |
return _events; | |
}); | |
var _b = document.getElementsByTagName('body')[0]; | |
_b.onclick = function(){alert('Hello world');} //click to see 'Hello world' | |
events.map(function(item) { | |
_b[item] = undefined; | |
}); | |
//click to see 'Hello world' no longer shows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment