troubleshooting Question

Need help to close the jsp page based on user choice

Avatar of gaugeta
gaugeta asked on
3 Comments1 Solution284 ViewsLast Modified:
Hi Experts...
I have a jsp page where if the user closes the page the popup box should appear asking whether he really wants to close the page.

If he chooses to close the page then i need to redirect to another jsp page using ajax.

How do i achieve the same.

I have a sample code which asks the user when he clicks the close button but this message is getting popped up when refresh,submit or clear buttons or any other buttons are pressed.

Can anyone sggest to modify the given code or any new functionality which achieves the same.

Please help...

<title>Refresh a page in jQuery</title>
<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<h1>Stop a page from exit with jQuery</h1>
<button id="reload">Refresh a Page in jQuery</button>
<script type="text/javascript">
	$('#reload').click(function() {
	$(window).bind('beforeunload', function(){
		return '>>>>>Before You Go<<<<<<<< \n Your custom message go here';
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros