If URL Contains 'affiliate1' Then do. For example: www.MyUncleVinny.com?affiliate1

Discussion in 'JavaScript' started by yashax, Oct 15, 2010.

  1. #1
    I have a website www.MyUncleVinny.com. We use affiliate codes for financial reporting. For example: www.MyUncleVinny.com?affiliate1

    How can I write a simple JavaScript function that will look at the URL and determine if it contains "affiliate1" then do something, like display image1, if the URL contains "affiliate2", then display image2, else display image3.

    Thank you SO MUCH in advance.
     
    yashax, Oct 15, 2010 IP
  2. krsix

    krsix Peon

    Messages:
    435
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This is not a smart idea, I'd suggset you catch this server side.
     
    krsix, Oct 15, 2010 IP
  3. yashax

    yashax Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    How do I do this?
     
    yashax, Oct 15, 2010 IP
  4. hdewantara

    hdewantara Well-Known Member

    Messages:
    540
    Likes Received:
    47
    Best Answers:
    25
    Trophy Points:
    155
    #4
    var aff = location.search.substr(1);
    Code (markup):
    if aff.length is not zero then it should give you the string.
     
    hdewantara, Oct 16, 2010 IP