Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

exit pop up question

Posted on 2014-12-26
4
Medium Priority
?
157 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 84

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 1000 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 1000 total points
ID: 40519637
Ignore me - completely misunderstood the Q
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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.
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…
Suggested Courses

773 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