Search code examples
javascriptonbeforeunload

Change default choice for onbeforeunload event


Is it possible to change the default option (if the user just presses enter) for the window.onbeforeunload event? The popup button defaults to "leave this page" (at-least in Chrome), and I was wondering if there is a way, in the function, to change this default to "stay on page".


Solution

  • It is not possible to change the button selected by default in an exit dialog without making a change to the user's web browser itself.