www.webdeveloper.com
Results 1 to 2 of 2

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

Hybrid View

  1. #1
    Join Date
    Oct 2010
    Posts
    1

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

    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.

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Code:
    var data = (location.search)? location.search.substring(1) : '';
    switch (data) {
        case 'affiliate1':
            // image1
            break;
        case 'affiliate2':
            // image2
            break;
        default:
            // image3
        }
    At least 98% of internet users' DNA is identical to that of chimpanzees

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles