Skip to main content

Bug Tracker

Side navigation

Ticket #2698: unload.js
File unload.js, 0.4 KB (added by flesler, June 24, 2008 06:38PM UTC)

Add this after jQuery.js

jQuery(window).unbind('unload').unload(function(){
	var elems = document.getElementsByTagName('*'),
		pos = elems.length + 1, // +1 for the document
		dummy = {};
	
	jQuery.data( dummy );
	for( var expando in dummy );
			
	while( pos-- ){
		var elem = elems[ pos ] || document, //add the document
			id = elem[expando];

		if( id && jQuery.cache[id] && jQuery.cache[id].events )
			jQuery.event.remove( elem );
	}
});

Download in other formats:

Original Format