[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

site exit message (exclude current domain)

Posted on 2010-01-04
16
Medium Priority
?
942 Views
Last Modified: 2012-05-08
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
Comment
Question by:binojpb
  • 8
  • 5
  • 2
  • +1
16 Comments
 

Author Comment

by:binojpb
ID: 26173031
We need a non-javascript solution.
0
 
LVL 43

Expert Comment

by:David S.
ID: 26177599
This is complicated enough with JavaScript. Without JavaScript this is just not possible.
0
 

Author Comment

by:binojpb
ID: 26180293
Is it possible with VB script or asp scripts ?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 6

Expert Comment

by:Tony O'Byrne
ID: 26180665
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
 

Author Comment

by:binojpb
ID: 26180989
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26181220
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
 
LVL 6

Assisted Solution

by:Tony O'Byrne
Tony O'Byrne earned 1500 total points
ID: 26181224
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
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 26181236
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
 

Author Comment

by:binojpb
ID: 26181819
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
 

Author Comment

by:binojpb
ID: 26181849
Just FYI, we have hundreds of external link on our site.
0
 
LVL 6

Accepted Solution

by:
Tony O'Byrne earned 1500 total points
ID: 26181951
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
 
LVL 6

Assisted Solution

by:Tony O'Byrne
Tony O'Byrne earned 1500 total points
ID: 26182371
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
 

Author Comment

by:binojpb
ID: 26182901
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
 

Author Comment

by:binojpb
ID: 26182975
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
 
LVL 6

Expert Comment

by:Tony O'Byrne
ID: 26183036
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
 

Author Closing Comment

by:binojpb
ID: 31672462
The solution is not on target.  More works need to be done.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

829 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