Link to home
Start Free TrialLog in
Avatar of binojpb
binojpb

asked on

site exit message (exclude current domain)

I am trying to launch a popup window when someone exits my site (I have links to several external sites from my website). I do not want the popup to launch when they click on an internal link but at the same time when they are about to leave my site,  I want to notify them that they are leaving my site and site policies of the new site may be different from ours.  Do you still wish to leave.  And give them options to leave the site or stay on my website.

We need a non-javascript solution.

Can someone help me with the code.  I am a newbee.
Avatar of binojpb
binojpb

ASKER

We need a non-javascript solution.
Avatar of David S.
This is complicated enough with JavaScript. Without JavaScript this is just not possible.
Avatar of binojpb

ASKER

Is it possible with VB script or asp scripts ?
Nope.  VB Script and asp scripts generate HTML on the server side, and the server delivers the generated HTML to the client.  Once that happens, the server wipes its hands clean and has nothing more to do with the operation of the site.  (Unless of course you're using ajax, but even then, that wouldn't work.)

The only way I can think of to do what you want is to attach a javascript method to the body tag...
onunload="javascript:testForLeaving()"

Other ideas - CSS is just for formatting and has nothing to do with page operation, and so can't check what's happening to the page.

HTML - this is just tags defining information.  Can't *control* what goes on in the page.

Flash - I would suspect not since the flash object will only be able to operate on actions within its own borders.

Either you use Javascript for this, or you go back to the client and tell them it ain't possible.
Avatar of binojpb

ASKER

Thanks Quaoar.  Just want to clarify a bit on the server side scripting option.  

Is it possible to identify at the server side when an external link is clicked?  
If so, can't we invoke the vb script to generate an HTML site exit message when that happens?

"Once that happens, the server wipes its hands clean and has nothing more to do with the operation of the site. "
This is little confusing
Can we have two working buttons on the generated HTML ?
1. Stay on the existing page
2. Continue to the external page

If we can have like this, how is the server going to identify and capture the external link that the user had clicked earlier?

I wan't to be thorough with the answer when I tell the client that it is not possible without javascript.
Here is what you CAN do without JS.

When you have a link in your site that points to an external site, you can run it through a page that produces the "goodbye" message.

What you cannot do is detect the browser actions (close, new URL, etc.) that a human might do by typing or mousing around.

An example of the "goodbye" script is here... The link would look like this:

<a href="goodbye.php?url=http://twitter.com">Twitter</a>
<?php // goodbye.php
error_reporting(E_ALL);

// REDIRECT TO AN OFFSITE LOCATION 

if (!isset($_GET["url"])) die("No URL");

echo "YOU ARE LEAVING THIS SITE<br/>";

echo "CLICK HERE TO GO: ";
echo "<a target=\"_blank\" href=\"{$_GET["url"]}\">{$_GET["url"]}</a>\n";

Open in new window

SOLUTION
Avatar of Tony O'Byrne
Tony O'Byrne
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Oops - sorry - just noticed you needed ASP not PHP.  Oh, well.  Maybe there is an ASP analog that would give you the same functionality.
Avatar of binojpb

ASKER

Yes.  I would like to know more about the <a href='external.asp?www.quaoar.com>Quaoar.com</a> method.
Sounds like we are seeing light at the end of the tunnel.  

From what you have suggested it looks like the asp script will have to generate a separate html for each external link which contains an anchor to the external link.

Is it possible to get the value of the external link dynamically into the asp script and to the html that is generated thereafter?

If so that would be the best solution for me.
Avatar of binojpb

ASKER

Just FYI, we have hundreds of external link on our site.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of binojpb

ASKER

I do get that part about refering to the external.asp file when an external link is clicked.

Please excuse my ignorance.

Let's say that the script generates an HTML frame with the following message

"You are leaving to an external site.  The security and privacy policies of the external site may be different from ours"  
Below two button.
"Continue to the external site" and "Cancel"

This is what the script should generate each time when we click an external link.  My question is, when some one clicks "Continue to the external site" .   From where does the button get the underlying url for the external link.

Do you mind sharing the code in the asp script file?

An example of what I am trying to do is here

http://egov.ocgov.com/ocgov/Info%20OC/OC%20Links/Orange%20County%20Links/State%20Government

They are using javascript.  We need the same replicated in vb script or asp.

1.pdf
Avatar of binojpb

ASKER

After posting the question and refreshing the page I now see that you have answered my question in a post later.

If you can share the code, it's great.  Otherwise I will work with my novice skills and post the code here for you to verify.

Thanks a lot.
I don't have anything on hand, and I'm not familiar with VBScript, so the stuff below is JScript pseudocode...  The general idea should work.
<%
    var targetUrl = Request.QueryString("url") ;
%>

<%
<div id="warningMessage">
You are leaving to an external site.  The security and privacy policies of the external site may be different from ours
<div id="okCancelButtons">
<a href="index.asp">Cancel</a>
<a href=<%=targetURL%>>Continue to external site</a>
</div>
</div>

<!--  something like this should get the job done in conjunction with all the above.  Name this file 'external.asp'  -->

Open in new window

Avatar of binojpb

ASKER

The solution is not on target.  More works need to be done.