This site will have limited functionality while we undergo maintenance to improve your experience. If an article doesn't solve your issue and you want to ask a question, we have our support community waiting to help you at @FirefoxSupport on Twitter and/r/firefox on Reddit.

Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

window.onunload is not working as expected.

  • 2 பதிலளிப்புகள்
  • 28 இந்த பிரச்னைகள் உள்ளது
  • 84 views
  • Last reply by BalajiPolisetty7

My Scenario .

On Close of the browser/ tab / refresh the tab we need to execute the piece of code.

All my code is in window.onbeforeunload which used to work in previous version of firefox .

But with the latest version code is executing only on closing the tab but not in the browser close or refresh . So i kept return statement in the window.onbeforeunload and all the code in the window.onunload . Now on click on the Leave this page it should call window.onunload and execute the code but in firefox it is not working like this. can you please provide me work around or solution for this.

Thanks alot.

My Scenario . On Close of the browser/ tab / refresh the tab we need to execute the piece of code. All my code is in window.onbeforeunload which used to work in previous version of firefox . But with the latest version code is executing only on closing the tab but not in the browser close or refresh . So i kept return statement in the window.onbeforeunload and all the code in the window.onunload . Now on click on the Leave this page it should call window.onunload and execute the code but in firefox it is not working like this. can you please provide me work around or solution for this. Thanks alot.

தீர்வு தேர்ந்தெடுக்கப்பட்டது

Call Firefox using a batch file, and have your code in the batch after Firefox.

Read this answer in context 👍 1

All Replies (2)

தீர்வு தேர்ந்தெடுக்கப்பட்டது

Call Firefox using a batch file, and have your code in the batch after Firefox.

please suggest if any other approaches we cannot use the suggested approach... or please let us know if this is bug in latest version so that will wait till it get resolved ... thanks