Skip to content

Instantly share code, notes, and snippets.

@jameswomack
Created August 16, 2012 22:05
Show Gist options
  • Save jameswomack/3374021 to your computer and use it in GitHub Desktop.
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
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