0

Ok so i have figured out how i can exit page with confirmation using window.onbeforeunload but how can i modify box that appears? Like adding css and html not only some text that says "Are you sure you want to exit this page?"

2 Answers2

2

There is very little you can do with the onbeforeunload event.

This is to prevent JavaScript from trapping a user.

Halcyon
  • 57,230
  • 10
  • 89
  • 128
0

Unfortunately, you cannot modify the dialog style.

You can just try to customize it as better as you can for your purposes, for example:

    window.onbeforeunload = function() {
        return 'You have unsaved changes!';
    }

Read the documentation about this topic on MSDN

Guern
  • 1,237
  • 1
  • 12
  • 30