Solved

exit pop up question

Posted on 2014-12-26
4
142 Views
Last Modified: 2015-02-11
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>
0
Comment
Question by:giancarlo barraza
  • 2
4 Comments
 
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 250 total points
ID: 40519535
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
 
LVL 58

Expert Comment

by:Gary
ID: 40519627
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
 

Author Comment

by:giancarlo barraza
ID: 40519634
so when closing the browser then is just closing forever right?

so no custom script?
0
 
LVL 58

Accepted Solution

by:
Gary earned 250 total points
ID: 40519637
Ignore me - completely misunderstood the Q
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now