0

I work with onbeforeunload to display a message with text area when closing pages, the problem is I am getting the message but not the text. The code I am using is :

window.addEventListener("beforeunload", function(event) {
                var response = prompt("Whay this page isn't good for YOU ?", "");
                //put the response in log file 
                //Exit the page 
            });

i tried so hard to get the prompt but no result.

Khalid
  • 1

1 Answers1

0

You can actually short hand it using window.onbeforeunload = yourfunction and then create your function which prompts the user.

EDIT

Apologies, it seems as though ASP.NET is allowing me to do something a bit weird, it seems like the easiest way to go about this is to append your function at the end of that as such: window.onbeforeunload = function(){ return "Say what you want!" } This will display a prompt before the window is closing, I'm sure you can replace it for whatever you like.

General Charismo
  • 123
  • 1
  • 1
  • 10