Jump to content

Adding 'unload' Event Handler


Recommended Posts

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...