exit pop up question

i have this code on my page and is it possible to redirect people on leave as well to another page instead of closing the page?

<script language="javascript">

var popmsg = "***************************************\n\n             W A I T !!! \n\nYoure missing out on this exclusive offer!\n\n-Penetrates deep within skins surface to deliver direct, concentrated treatment.\n\n-The transformation is immediate. See the radiant, younger looking skin you want. Today and tomorrow!\n  \n    CLICK THE *Stay on this Page* BUTTON RIGHT NOW\n To Get Celluxe Advanced  Anti-Aging AND \n   Dermactiv Advanced Vitamin C Eye Serum  FOR LESS THAN $3.95 for BOTH!\n\n***************************************";

var redirectURL = "http://domainn.com/exitpop.php?c1=exit-oprah";

</script>
<script language="javascript" src="popup.js"></script>
giancarlo barrazaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David Johnson, CD, MVPOwnerCommented:
you are looking for the onbeforeunload
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>

<head>
<title>onbeforeunload Event Sample</title>
<link rel="stylesheet" href="samplesSDKIE4.css" type="text/css">
<script type="text/javascript">
function closeIt()
{
  return "Any string value here forces a dialog box to \n" + 
  	     "appear before closing the window.";
}
window.onbeforeunload = closeIt;
</script>
</head>

<body>

<!--TOOLBAR_START-->
<!--TOOLBAR_EXEMPT-->
<!--TOOLBAR_END-->
<div class="body">
	<h1>onbeforeunload Event Sample</h1>
	<p>This example uses the <b>onbeforeunload</b> event to ask users whether they 
	want to remain on the current page or navigate to a new URL. </p>
	<p>When the user clicks on the hyperlink or attempts to close the browser window, 
	the <b>onbeforeunload</b> event fires on the body and a dialog box appears. 
	If the user clicks <strong>OK</strong> in the dialog box, the page either navigates 
	to the new URL or the window closes; otherwise, the page remains the same.</p>
	<a href="http://www.microsoft.com">Click here to navigate to www.microsoft.com.</a>
	<!-- START_PAGE_FOOTER --><br>
	<br>
	<br>
	<p class="viewsource">[Right-click and choose View Source from the shortcut 
	menu.] </p>
	<a class="copyright" href="http://www.microsoft.com/isapi/gomscom.asp?TARGET=/info/cpyright.htm">
	© 2007 Microsoft Corporation. All rights reserved. Terms of use.</a>
	<!-- END_PAGE_FOOTER --></div>

</body>

</html>

Open in new window


http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/onbeforeunload.htm
0
GaryCommented:
You have two options - stay on page/leave page (close tab)
You can't redirect - this "feature" was abused too much by spammers that all modern browsers severely restricted what you can and can't do when someone is attempting to close the tab/browser
0
giancarlo barrazaAuthor Commented:
so when closing the browser then is just closing forever right?

so no custom script?
0
GaryCommented:
Ignore me - completely misunderstood the Q
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.