Solved

exit pop up question

Posted on 2014-12-26
4
144 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 79

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
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…

832 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