0

Hello,

How to force window.onbeforeunload to act only on pertular action or url?
I have a form which has data. if it navigates to another page then
window.onbeforeunload= function() { return "please save data"; };
is working.
But after submission of that page, it navigates to another page on that cation also it is asking me for saving data.
which I dont want.
I want it just for that page url.
Is it possible?
how?

3
Contributors
3
Replies
15
Views
3 Years
Discussion Span
Last Post by Priti_P
0

Try something like this...

if ( window.location.toString().indexOf("myPage.html") > -1 ) {
    window.onbeforeunload...
}
0

How about something on the submit button
onclick='window.onbeforeunload = null;'
or on

form.submit.

Edited by almostbob

1

Hello,
Thanks AleMonteiro and almostbob!!
@almostbob: your solution worked for me!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.