Can you improve upon this javascript redirect?

Discussion in 'JavaScript' started by Miles Baker, Nov 1, 2006.

  1. #1
    I am using this javascript code for redirecting and cloaking affiliate links. Just wondering if anyone had any suggestions or tips to make it better. It seems to do the job and set the affiliate tracking cookie.

    I know a few basics of javascript, but I am trying to learn. Can someone clarify what's happening in this script exactly? I understand the frame and onload parts, but the OnT and OnT2, what is that doing?

    Thank You!

    <html>
    <head>
    <title>My Big Title</title>
    <script language="JavaScript">
     
     var Test = null;
     
     function SymError()
     {
       return true;
     }
     
     function OnT()
     {
    	window.status = "Blah Blah Blah";
     }
    
     function OnT2()
     {
     	if (Test != null) {
     		clearInterval(Test);
     	}
     }
     
     
     window.onerror = SymError;
     Test = setInterval("OnT()", 100);
     
    </script>
    </head>
    <FRAMESET border=0 frameSpacing=0 rows=* frameBorder=0 marginbottom=0 marginright=0 margintop=0  marginleft=0>
    <FRAME border=0 src="http://www.myaffiliatelink.com?affiliate" frameBorder=no noResize OnLoad="OnT2()" id="frmMai" name="a">
       <noframes>
     <body onload='document.location="http://www.myaffiliatelink.com?affiliate; OnT();"'>
     </body>
       </noframes>
    <script language="JavaScript" type="text/javascript">
    	OnT();
    </script>    
    </html>
    Code (markup):
     
    Miles Baker, Nov 1, 2006 IP
  2. Richie_Ni

    Richie_Ni Illustrious Member

    Messages:
    10,721
    Likes Received:
    1,175
    Best Answers:
    0
    Trophy Points:
    410
    #2
    Why don't you use .htaccess to do that?
     
    Richie_Ni, Nov 1, 2006 IP
  3. Miles Baker

    Miles Baker Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    .htaccess will redirect it, but it won't cloak the URL in the browser when they land on the affiliate site.
     
    Miles Baker, Nov 1, 2006 IP
  4. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Sure it will, use .htaccess with redirect 301.
     
    Morishani, Nov 2, 2006 IP
  5. Miles Baker

    Miles Baker Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Uh, no it won't. It won't leave your URL in the browser when the new site is loaded on the page. It only redirects, it doesn't cloak.
     
    Miles Baker, Nov 2, 2006 IP
  6. cdedbd

    cdedbd Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    So you want to redirect but keep the URL?
     
    cdedbd, Nov 3, 2006 IP
  7. Miles Baker

    Miles Baker Peon

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Yes, I do.
     
    Miles Baker, Nov 3, 2006 IP