Javascript redirect based on refferer.

Reply Tue 14 Jan, 2003 06:53 pm
This is a script I used to redirect visits from a certain site to a specific page.

I then used a meta refresh tag to direct them back to the referring site but this can be used simply to display a custom page based on where the visitor was referred from.


Code:<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var refarray = new Array();
refarray['domain1.com'] = "http://www.able2know.com/pagefordomain1.htm";
refarray['domain2.com'] = "http://www.able2know.com/pagefordomain2.htm";
refarray['domain3.com'] = "http://www.able2know.com/pagefordomain3.htm";
for (var i in refarray) {
if (document.referrer.indexOf(i) != -1) window.location.replace(refarray[i]);
// End -->

Replace each domain in the array to the ones you want to add as refferers and specify the page to use as a redirect using the URL format shown above.
  • Topic Stats
  • Top Replies
  • Link to this Topic
Type: Discussion • Score: 1 • Views: 7,749 • Replies: 2
No top replies

Reply Wed 15 Jan, 2003 09:19 am
I take it this is how redirection works for expired web pages (e. g. X page has expired. Your browser will now redirect you to the Y page. Click here if your browser doesn't redirect you in five minutes)?
0 Replies
Craven de Kere
Reply Wed 15 Jan, 2003 11:25 am
The pages that direct you to a new page are probably using a meta refresh tag, this is a bit different because there is no option for a timed delay (with the meta refresh you can choose how many seconds it takes) and it only redirects you if the site that referred you in in the javascript array.

Here is the meta refresh code. It's very simple.
0 Replies

Related Topics

In How much time a website can be developed? - Question by aussiejumpingcastle
Webdevelopment and hosting - Question by harisit2005
Showing an Ico File - Discussion by Brandon9000
how to earn money in internet - Discussion by rizwanaraj
The version 10 bug. Worse then Y2K! - Discussion by Nick Ashley
CSS Border style colors - Question by meesa
There is no Wisdom in Crowds - Discussion by ebrown p
THANK YOU CRAVEN AND NICK!!! - Discussion by dagmaraka
I'm the developer - Discussion by Nick Ashley
  1. Forums
  2. » Javascript redirect based on refferer.
Copyright © 2021 MadLab, LLC :: Terms of Service :: Privacy Policy :: Page generated in 0.03 seconds on 06/16/2021 at 08:15:56