Jquery code question

Discussion in 'Black Hat SEO' started by Eagle Eye, May 10, 2012.

  1. Eagle Eye

    Eagle Eye Senior Member

    Joined:
    Aug 3, 2010
    Messages:
    1,123
    Likes Received:
    642
    Gender:
    Male
    Occupation:
    Achiever
    Location:
    East Coast
    I am trying to redirect all outbound links on my wp site to another domain. so when someone clicks any outbound link they land on the other domain. I have this J query code that I was told would do the job I just do not know how to set it up on my server so that it handles all outbound links on my site in this manner.

    Here is the code:

    Code:
    $('a').each(function(x) {$(this).attr('href',this.href.replace('olddomain','newdomain'));})
    Can someone tell me how to set it up on my server?
     
  2. Eagle Eye

    Eagle Eye Senior Member

    Joined:
    Aug 3, 2010
    Messages:
    1,123
    Likes Received:
    642
    Gender:
    Male
    Occupation:
    Achiever
    Location:
    East Coast
    any ideas?
     
  3. bobred

    bobred Junior Member

    Joined:
    Dec 21, 2011
    Messages:
    111
    Likes Received:
    70
    Presuming you already have jquery included on the site in question, you would need to place that in a script tag in the head section of your html. However the code you have will only work if all of the links you want to change are already pointing to a single olddomain.com, if they're pointing to multiple domains then you would need to paste that line multiple times changing the olddomain each time.