csenthilkumar87 Posted March 10, 2009 Share Posted March 10, 2009 I am developing a Firefox extension. My problem is not Firefox-specific.I detect page load and create an object that holds some information. After the user closes the tab, or navigates to another URL in the same tab, I no longer need that object, as I will be creating a new one for the newly loaded page.The problem is, I have to set that object to null, when that page unloads. But I am not able to detect 'unload' event. function setEvtListener(){ // Here I can access the document using window.content.document // But the following line does not work - // (doSomething is a well known function) window.content.document.body.addEventListener('unload', doSomething, false); // Neither does this.. // window.content.document.getElementsByTagName('body')[0].addEvent.....} Can someone help me?Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted March 10, 2009 Share Posted March 10, 2009 This should work:window.addEventListener('unload', function() { alert ('unload'); }, false);window.addEventListener('load', function() { alert ('load'); }, false); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.