• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 948
  • Last Modified:

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.
0
binojpb
Asked:
binojpb
  • 8
  • 5
  • 2
  • +1
3 Solutions
 
binojpbAuthor Commented:
We need a non-javascript solution.
0
 
David S.Commented:
This is complicated enough with JavaScript. Without JavaScript this is just not possible.
0
 
binojpbAuthor Commented:
Is it possible with VB script or asp scripts ?
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

 
Tony O'ByrneSenior Web DeveloperCommented:
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.
0
 
binojpbAuthor Commented:
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.
0
 
Ray PaseurCommented:
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

0
 
Tony O'ByrneSenior Web DeveloperCommented:
You can't identify (on the server side) when an external link is clicked...  This is because when the link is clicked, the browser goes to the server that the external link refers to.  So if your domain is www.binojpb.com and an external link points to www.quaoar.com, when someone clicks on the external link, the browser talks to www.quaoar.com

Communication between browser  & server needs to be kept to a minimum, so once the server delivers the content to the browser, the server closes the connection.  Everything is then handled by the browser.  If the browser sees a relative link, or a link that points to your domain, *then* it communicates with your server.

If on the other hand, the browser sees a link that goes to www.someOtherWebSite.com it opens a connection with that other server to request the default (or requested page).  There is just no need for it to communicate with your server at this point - it knows it's looking for something that's not on your server, so it doesn't ask your sever for it :)

In saying all of that, your previous post did give me an idea...  Something I have used in the past, but just totally forgot about.

For external links you can do something like this...

<a href='external.asp?www.quaoar.com>Quaoar.com</a>

This way you're pointing to an internal .asp script, you can spit out maybe a message asking if the user is sure they want to leave.  You will *need* to pass the external link into the .asp script 'cos the user did click on it, and if they really meant to, then you need to do it.

So, external.asp might do something like:
  • Spit out some generated HTML or
  • make a note of whatever it is you want to make a note of and
  • at the bottom include a regular anchor - <a href="www.quaoar.com">Continue to external site...</a>
This method *will* force communication with your server without Javascript.

Hopefull this helps clear things up...

If you need to talk more about this "external.asp?www.ebsite.com" business, just shoot a reply back :)  We can certainly discuss it further.
0
 
Ray PaseurCommented:
Oops - sorry - just noticed you needed ASP not PHP.  Oh, well.  Maybe there is an ASP analog that would give you the same functionality.
0
 
binojpbAuthor Commented:
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.
0
 
binojpbAuthor Commented:
Just FYI, we have hundreds of external link on our site.
0
 
Tony O'ByrneSenior Web DeveloperCommented:
There's not much more being done here than what's already being done...You're already drawing hundreds of URLs, but the ASP script doesn't need to do anything.  It's something that you can hard-code into those links that you know are going to be external...

So if you know that link #1 is going to google -
<a href='http://www.google.com'>Google</a>

Just type in "external.asp?" in front of the "http://".  A simple search/replace in your editor should take care of it all real quick - search for "http://" and replace with "external.asp?http://"

So for the most part, your code is staying pretty much the same.

0
 
Tony O'ByrneSenior Web DeveloperCommented:
I just noticed a bit of an issue with the above - it's not complicated, but it'll stop things from working.  Rather than doing "external.asp?http://www.externalSite.com", you should do "external.asp?url=http://www.externalSite.com"

So include that in your search/replace.

Also, when it comes to actually figuring out where the user was trying to go, you'll need to get the url from the url string.

[dim | var] url = Request.QueryString("url") ;  //  dim | var - depends on whether you're using VBScript or JScript.

0
 
binojpbAuthor Commented:
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
0
 
binojpbAuthor Commented:
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.
0
 
Tony O'ByrneSenior Web DeveloperCommented:
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

0
 
binojpbAuthor Commented:
The solution is not on target.  More works need to be done.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 8
  • 5
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now