Need the custom message to display instead of "Changes you made may not have been saved." on page refresh

On page refresh I wanna throw pop up to the user “You’ll go to default screen”. So I wrote a code in my Jquery as

$(window).bind(‘beforeunload’, function(){
return window.confirm(“You’ll go to default screen”);

It works fine but it always throw the different message as “Changes you made may not have been saved.”, instead I need my custom message over here.

Thanks in advance !

Just return a string instead of the window.confirm.

No, It’s same when returning string.It gives the same message.

More recent web browsers won’t show the custom message, because it was considered to be a security issue.

So now what can be done in order to achieve it as my client is demanding to change the default message.

You need to be honest and tell them that modern web browsers no longer allow that to occur.

Because modern browsers no longer allow this, a better solution is to automatically save the changes so that if the person returns back to the page, they can be given the option to restore from the saved information.

1 Like

Why modern browsers doesn’t support it. What’s the security threat does this pop up makes?

Sometimes the next web page that the user is visiting is exposed.

On other occasions, bad websites give false information in the message, that result in the user being scammed, where each iframe can when closed trigger another iframe to popup.

As a result of bad sites, onbeforeunload has been restricted in order to help protect users.!msg/blink-dev/YIH8CoYVGSg/Di7TsljXDQAJ

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.