Solved

exit pop up question

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

707 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

12 Experts available now in Live!

Get 1:1 Help Now