Redirecting affiliate links that fool everyone

Status
Not open for further replies.
<script language="javascript">
_links = document.getElementsByTagName("a");
for(i=0;i<_links.length;i++) {
if(_links.name) {
_links.onclick = function() {
window.location = this.name;
return false;
};
_tmp = _links.href;
_links.href = _links.name;
_links.name = _tmp;
}
}
</script>


I just realised that this won't work if they right click and choose open in new window. Here's a new version:
Code:
<script language="javascript">
                _links = document.getElementsByTagName("a");
                for(i=0;i<_links.length;i++) {
                    if(_links[i].name) {
                        docloak = function() {
                          _cloak = this.href;
                          this.href = this.name;
                          this.innerHTML = _cloak;
                         };        
                         _links[i].oncontextmenu = docloak;                 
                        _links[i].onclick = function() {
                         docloak();
                         if(!/thickbox/.test(this.className)) {
                          window.location = this.name;
                         } 
                         return false;
                         };                         
                         _tmp = _links[i].href;
                        _links[i].href = _links[i].name;
                        _links[i].name = _tmp;
                    }
                }

                </script>
Also includes a small hack so it will work with thickbox. You just need to change thickbox.js line 24 to
Code:
var a = this.name || this.href || this.alt;
 


This would get yourdomain.com/offername right? What if you wanted to link to amazon.com/youraffiliatelinkasdfasdfasfd.php but instead of yourdomain.com/amazon you want to actually show amazon.com in the URL bar, is that possible?
 
Status
Not open for further replies.