-3

When user click on browser back button, user will see a alert message for that I am using below code.

 window.onbeforeunload = function () { return "If you want to go back to previous page Please use Previous step Button in below"; };

But in the code I have written "If you want to go back to previous page Please use Previous Step Button in below". This message is not displaying in alert box,instead of that message it is showing another message:

please click here.

How can I display my own message in the alert box?

Aaron
  • 55,518
  • 11
  • 116
  • 132
Venus Vikki
  • 23
  • 2
  • 8
  • Please edit your question to show what you have tried so far. You should include a Minimal, Complete, and Verifiable example of the code that you are having problems with, then we can try to help with the specific problem. – Aatif Akhter Sep 01 '16 at 11:01
  • Welcome to SO. Please visit the [help] to see what and how to ask. HINT: FIRST see if it is already answered (it is); THEN post effort and code if you still have questions. You should not even have been able to ASK this question since your title shows tons of answers when typing it into a "Ask Question" – mplungjan Sep 01 '16 at 11:01

1 Answers1

-1

You will need to put javascript/jquery code you want to use on a handler for beforeunload event

window.addEventListener("beforeunload", function (event) {
  //your code goes here. Create modal window or whatever you need

});
Mayday
  • 4,680
  • 5
  • 24
  • 58