Web Hosting Talk







View Full Version : Can this be done with java script?


Dave22
11-08-2002, 10:41 AM
I have a exit popup on my site and when some people come to my site from like yahoo or google i don't want those people to get the popup is there a way to put urls in the Java script so it will know not to open a exit window when the referring url is google or yahoo?

If Java script can't do it what can?

Thanks

iamdave
11-08-2002, 06:12 PM
Originally posted by Dave22
I have a exit popup on my site and when some people come to my site from like yahoo or google i don't want those people to get the popup is there a way to put urls in the Java script so it will know not to open a exit window when the referring url is google or yahoo?

If Java script can't do it what can?

Thanks This should be in the Programming Discussion Forum, but to answer your question, you should be able to do it with some php code. For example if refer doesn't = google or yahoo then do the pop-up...

smidwap
11-08-2002, 06:29 PM
Originally posted by iamdave
This should be in the Programming Discussion Forum, but to answer your question, you should be able to do it with some php code. For example if refer doesn't = google or yahoo then do the pop-up...
Yes, but how are you supposed to activate the script when the visitor leaves the site? :eek: You'll need a client-side scripting language to do that.

Check out www.javascriptsource.com; I'm sure you'll find something. :D

iamdave
11-08-2002, 07:23 PM
Originally posted by smidwap

Yes, but how are you supposed to activate the script when the visitor leaves the site? :eek: You'll need a client-side scripting language to do that.

Check out www.javascriptsource.com; I'm sure you'll find something. :D You can still do it, to show the javascript or not would be decided before the user even saw the page. php=serverside.

tapster
11-08-2002, 07:32 PM
can be done on the client side too using document.referrer

something like...

<script>
if (document.referrer != "http://yahoo.com")
{
// your popup code here
}
</script>

you may need to manipulate the document.referrer string to extract the "yahoo.com" bit...

experiment :)

Dave22
11-09-2002, 10:29 AM
I don't know anything about java script so i can't experiment :(