By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,945 Members | 1,692 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,945 IT Pros & Developers. It's quick & easy.

Stopping navigation away from the page

P: n/a
Hi,

In our ASP .NET application we present a form wherein the user has to
input a number of fields. If in the middle of filling the form, the
user accidentally navigates away from the page, either by clicking a
link on the page or hitting an entry in the Favorites or in any way,
we want to present an alert with only the OK button, which when
clicked will keep the user on the same page and avoid the navigation
out of the page.

If we do it in the onbeforeunload event, we get a standard popup with
OK and CANCEL. When Cancel is clicked, the user navigates away. We
want to avoid this.

Can you please suggest a way? Is there a way to capture the navigation
event and suppress it?

Thanks,
Yash
Jan 31 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jan 31, 5:22 am, Yash <yas...@gmail.comwrote:
Hi,

In our ASP .NET application we present a form wherein the user has to
input a number of fields. If in the middle of filling the form, the
user accidentally navigates away from the page, either by clicking a
link on the page or hitting an entry in the Favorites or in any way,
we want to present an alert with only the OK button, which when
clicked will keep the user on the same page and avoid the navigation
out of the page.

If we do it in the onbeforeunload event, we get a standard popup with
OK and CANCEL. When Cancel is clicked, the user navigates away. We
want to avoid this.

Can you please suggest a way? Is there a way to capture the navigation
event and suppress it?

Thanks,
Yash
1) What is the point in presenting only one option "OK"? Are you
working for early Microsoft (an error occurred - click "OK" to
continue)?
2) If the user does not have a choice then there is NO point in
presenting the box, but you can still use std alert()
3) If you put this script in onUnload event, your user will NEVER be
able to leave the page, or are you going to put some code in Submit
button onClick event to disable the onUnload code?
Jan 31 '08 #2

P: n/a
Yash wrote:
If we do it in the onbeforeunload event, we get a standard popup with
OK and CANCEL. When Cancel is clicked, the user navigates away. We
want to avoid this.
That sounds like a bad idea. Why would you want to not allow a user to
leave ? I agree catching them and asking if they're sure they want to
abandon what they were doing is a good idea, but preventing them from
doing it doesn't sound sensible.
Jan 31 '08 #3

P: n/a
On Jan 31, 5:26*pm, Stevo <ple...@spam-me.comwrote:
Yash wrote:
If we do it in the onbeforeunload event, we get a standard popup with
OK and CANCEL. When Cancel is clicked, the user navigates away. We
want to avoid this.

That sounds like a bad idea. Why would you want to not allow a user to
leave ? I agree catching them and asking if they're sure they want to
abandon what they were doing is a good idea, but preventing them from
doing it doesn't sound sensible.
I want to present only an OK because the user should be made aware of
why he is not being allowed to leave. When he cliks OK, he will be
back on the page.

There will be special flag set onclick of the Submit button to exempt
it from the above check. So only on Submitting, the user will be able
to leave the page.

This is a client requirement and we have no control over it.
Jan 31 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.