Closed Thread Icon

Topic awaiting preservation: unusual client request (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=8577" title="Pages that link to Topic awaiting preservation: unusual client request (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: unusual client request <span class="small">(Page 1 of 1)</span>\

 
patric design
Bipolar (III) Inmate

From: 290 km/h, fast lane, Autobahn, Germany
Insane since: Feb 2001

posted posted 03-19-2003 14:34

Hi all!

A client of mine has come up with a request that i wouldn't usually follow as the method is often abused on the net.
My client wants a popup when the user leaves the site saying "thank you for visiting our website bla bla bla".
The page is buildt using Dreamweaver Templates and it is a css & xhtml only site, no frames no tables, no fuss.
Now the problem is that when i use the onUnload event, the popup will open when ANY link is clicked, regardless if it is on the clients domain or not.

How can I create a popup that will only come up when someone actually leaves the site?
I know this is a horrible practice and i've tried a thousand times to convince him not to do this but he wants it... :-(

<´¯`·.¸ Patric ¸.·´¯`>

reitsma
Maniac (V) Mad Scientist

From: the bigger bedroom
Insane since: Oct 2000

posted posted 03-20-2003 00:48

this sort of thing may need a bit of experimenting...

i can't provide much practical help at the moment, but i suppose you would need to find out what sort of variables are available at that point in time on the browser. are you able to see where the user is going?

if not, then the simplest (yet rather annoying) way i can think of offhand is to have on all local links:

<a href="www.ourdomain.com/thislink.html" onclick="localSite=true;">

....and then have on your onunload:
if(!localSite) alert("YAH! I am an annoying company who somehow believes that this will improve your online experience!");

or similar.

well, good luck!

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 03-20-2003 02:47

Reitsma's idea gave me an idea for a simpler way to do this, that won't be so difficult... use this script:

<script type="text/javascript">
window.onload = function() {
var anchors = document.getElementsByTagName('a');
for (var a=0; a < anchors.length; a++)
{
/* if the anchor links outside of the page (it contains "://" as in "http://", but not "ourdomain.com")... */
if (anchors[a].href.indexOf("://") != -1 && anchors[a].href.indexOf("ourdomain.com") == -1)
{
anchors[a].onclick = GoodbyeMessage;
}
}
}

function GoodbyeMessage()
{
alert("Doesn't this alert make you so glad you visited our page?");
}
</script>

Untested code, but maybe you get the general idea from it. The logic of the if condition may need improvement to work in 100% of cases.

[This message has been edited by Slime (edited 03-20-2003).]

« BackwardsOnwards »

Show Forum Drop Down Menu