Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 3rd, 2005, 06:12 AM
Authorized User
 
Join Date: Jun 2003
Location: Indore, M.P., India.
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sandeep
Default prompt user before exiting

Hi!
     I have a asp.net form. I need to prompt user something like 'Are you sure you want to exit?' by using confirm. If the user clicks cancel button i need to stay on that form else i need to close the form. The unload event of window doesn't allow to cancel the event. Is there any work around to do it? Also i need to show the same message if the user goes to some other page from same browser. Any help will be greatly appreciated.

Thanking you

Regards
Sandeep Saran
 
Old September 5th, 2005, 01:42 PM
Friend of Wrox
Points: 894, Level: 11
Points: 894, Level: 11 Points: 894, Level: 11 Points: 894, Level: 11
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: London, , United Kingdom.
Posts: 166
Thanks: 2
Thanked 33 Times in 33 Posts
Default

Hi Sandeep

you need to use the onbeforeunload event, which fires right before onunload. You can get the user to confirm, by simply setting event.returnValue to the text you want to use. So something like:
<BODY onbeforeunload="event.returnValue='Are you sure?'">

I could only get this to work in internet explorer tho.

Hope this helps
Philip Cole




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to prompt user for password Imtiaz Ahmed Classic ASP Professional 1 June 21st, 2007 05:28 PM
how to prompt user if they try to delte wrong valu method ASP.NET 1.x and 2.0 Application Design 4 June 17th, 2005 08:32 AM
A better way of exiting jaucourt VB.NET 2002/2003 Basics 1 March 31st, 2004 07:44 PM
How to prompt user Internet Connection Wizard? joan VS.NET 2002/2003 0 September 30th, 2003 10:31 PM
exiting MyAccount.aspx robert BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 17th, 2003 11:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.