Join the Mozilla’s Test Days event from Dec 2–8 to test the new Firefox address bar on Firefox Beta 134 and get a chance to win Mozilla swag vouchers! 🎁

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

browser/tab close event (onbeforeunload) is not working

  • 1 reply
  • 3 have this problem
  • 2 views
  • Last reply by cor-el

more options

window.onbeforeunload = function (e) { // Your logic to prepare for 'Stay on this Page' goes here

   return "Please click 'Stay on this Page' and we will give you candy";

};

i have used above query.

window.onbeforeunload = function (e) { // Your logic to prepare for 'Stay on this Page' goes here return "Please click 'Stay on this Page' and we will give you candy"; }; i have used above query.

All Replies (1)

more options