Simple javascript help, please!

Discussion in 'JavaScript' started by Senior92, Nov 17, 2010.

  1. #1
    Hello,
    I am trying to modify this code:
    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var requiredfrom = "http://example.com/1.htm"; //  
    if (document.referrer.indexOf(requiredfrom) == -1) {
    alert("Error: TEXT");
    window.location=requiredfrom;
    }
    //  End --></SCRIPT>
    
    Code (markup):
    The previous code should force any visitor to it's container page to visit "example.com/1.htm" first (visitor can visit the page if example.com/1.htm redirects to it, or contains a link - referrer).
    I need to add another page like (example.com/1.htm) to the code. I want 2 pages to be able to send traffic to the page, not just 1.
    Any help?
    Sorry for my English & thank you.
     
    Senior92, Nov 17, 2010 IP
  2. sponsorlist

    sponsorlist Peon

    Messages:
    32
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can add another condition like this:

    
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    var requiredfrom = "http://example.com/1.htm"; //  
    var requiredfrom2 = "http://example.com/2.htm"; //  
    if ((document.referrer.indexOf(requiredfrom) == -1) && (document.referrer.indexOf(requiredfrom2) == -1) ) {
    alert("Error: TEXT");
    window.location=requiredfrom;
    }
    //  End --></SCRIPT>
    
    Code (markup):
    But be aware that some browsers or firewalls might have a setting to disable referrers(or javascript) so this might not work for everyone.
     
    sponsorlist, Nov 18, 2010 IP
    Senior92 likes this.
  3. Senior92

    Senior92 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thank you, sponsorlist. I really appreciate your help. :)
     
    Senior92, Nov 18, 2010 IP