Web Analytics Made Easy -
StatCounter Help using referrer for multiple popups or redirects - CodingForum

Announcement

Collapse
No announcement yet.

Help using referrer for multiple popups or redirects

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help using referrer for multiple popups or redirects

    Hi, I want to use the document.referrer property to pop up a selection of pages depending on where the visitor links from. I've found lots of scripts that will pop up on a single referrer URL but nothing that will make a selection from a number of pages based on different referrers. Alternatively, I could use the referrer property to load a different page into an iframe.

    I should add that if you give me a code snippet I may not know what to do with it but I will do my best!

    I thought JS would be a good place to start with this but am happy to use PHP if you think that's better.

    many thanks in advance

    Pete

  • #2
    You mean something like this?
    Code:
    switch (document.referrer) 
    { 
       case "http://www.google.com" : 
          window.open("page1.htm","[i]nameOfTargetIframe[/i]");
          break; 
       case "http://www.yahoo.com" : 
          window.open("page2.htm","[i]nameOfTargetIframe[/i]");
          break; 
       case "http://www.microsoft.com" : 
          window.open("page3.htm","[i]nameOfTargetIframe[/i]");
          break; 
       //and so on
    
       default : 
          window.open("default.htm","[i]nameOfTargetIframe[/i]");
    }
    Glenn
    vBulletin Mods That Rock!

    Comment


    • #3
      Looks pretty good...now I have to ask some dumb questions:

      Where do I put that?

      I presume that goes by itself inside the usual script tags?

      thanks for your help

      Comment


      • #4
        oh, another question - can I also do this based on their hostname or IP address i.e. their own domain name as well as document.referrer

        If so, can I mix the two in the same script?
        Last edited by peterfreeth; Feb 24, 2004, 05:30 AM.

        Comment


        • #5
          It's better to do it in PHP then.
          Glenn
          vBulletin Mods That Rock!

          Comment

          Working...
          X