Solved

Popup Survey when Leaving domain

Posted on 2004-10-07
12
482 Views
Last Modified: 2008-02-07
I need to launch a shopper survey when the shopper leaves the website.
This means the survey must appear if the visitor:
A) navigates to a different domain,   or
B) closes the browser

The survey must popup reliably for any user regardless of browser.
This is VERY important to this e-commerce site, please help!
0
Comment
Question by:DougCoulter
  • 5
  • 4
12 Comments
 
LVL 33

Expert Comment

by:sajuks
ID: 12255905
<body onunload ="CallFunction()">

Where  the CallFunction will be something like
function CallFunction()
{
window.open ("popup.html","popup:)
}
0
 
LVL 30

Expert Comment

by:third
ID: 12255912
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12255918
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:DougCoulter
ID: 12256391
sajuks,

your approach creates a pop-up when leaving the domain BUT
also when remaining within the domain.

doug
0
 
LVL 33

Accepted Solution

by:
sajuks earned 250 total points
ID: 12256501
// this code should've worked for you
<html>
<head>
<script>
function checkExit(){
     var win = window.open("","","width=10,height=10");
     win.blur();
     win.document.write("<script>");
     win.document.write("setTimeout(\'checkDomain()\',1000);\n");
     win.document.write("function checkDomain(){ ");
     win.document.write("try {");
     win.document.write("if(window.opener) var x = window.opener.location.href;\n");
     win.document.write("self.close();}");
     win.document.write("catch(e){window.alert(\'you left my domain!!!\'); self.close();}");
     win.document.write("}");
     win.document.write("<\/script>");
}
</script>
</head>

<body onunload="checkExit();">
<a href="closeDomain.html">stay at domain</a><br>
<a href="http://www.experts-exchange.com">leave domain</a><br>
</body>
</html>
0
 

Author Comment

by:DougCoulter
ID: 12256610
sajuks,
i can generate an alert with this but i need to generate a popup asp survey form.
will it work for something like:
win.document.write("catch(e){var win = window.open('survey.asp','survey','height=650,width=500');}");
doug
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12256742
Oh yes.Thats should work
Are you getting any errors?
0
 

Author Comment

by:DougCoulter
ID: 12256785
not getting the pop-up.

i need to make a database entry and launch an asp form based on the visitor leaving the domain.
the database code is simply:
<% sql = 'UPDATE tracking SET survey2 = '1' WHERE sessionID='" + Session.SessionID + "'";
connection.Execute(sql);%>
in asp. . . . . . .is there some way to execute that as part of the checkExit function?
0
 
LVL 33

Expert Comment

by:sajuks
ID: 12256834
In the example were you getting the alert right ?
That means there must be something wrong in the windows open script.
This works for me
win.document.write("catch(e){var win = window.open('survey.asp','survey','height=650,width=500');}");

Are you sure that the popup is not closed by any popup killer ( like google toolbar or firewall?)
0
 

Author Comment

by:DougCoulter
ID: 12263297
sajuks,

I can get the alert,
I get the initial 10x10 window,
but I am unable to get another window to popup.

So, you're right, there must be something wrong with the the windows open script,
there is no problem with popup blockers, i can get popups when there are no conditionals.

i have tried:
win.document.write("catch(e){var win = window.open('survey.asp','survey','height=650,width=500');}");
which seems like a simple replacement for the alert, but no luck.

Any suggestions?
doug
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…

830 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