Results 1 to 6 of 6

Thread: Using JS to Hide Links

  1. #1
    ruffneck119 is offline Unknown Net Builder
    Join Date
    Dec 2009
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post

    Using JS to Hide Links

    I have looked all over no one has a solid script to hide a link using JS. I used this code but it will not open in the same window. Can anyone help me make it open in the same window? Or do you have your own code to hide links from Google?

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
    
    function url() {
    hidden = open('http://www.url.com');
    }
    
    // End -->
    </script>
    
    
    <A HREF="javascript:url()" ><IMG SRC="image.jpg" border="0"></A>

  2. #2
    Mike-XS's Avatar
    Mike-XS is offline XeroAgent
    Join Date
    Sep 2009
    Location
    OZ
    Posts
    206
    Thanks
    30
    Thanked 108 Times in 71 Posts
    I had some js code that would help but I can't find it right now..

    I have looked all over no one has a solid script to hide a link using JS.
    Look harder.. ?

    For hiding links from Googlebot check out this discussion - SEOmoz | YOUmoz - New Reality: Google Follows Links in JavaScript. , there's a few good suggestions in the comments - like this one and here's some example code here you could try.

    And you may find this youtube vid interesting too: Can I disallow crawling of my CSS and JavaScript files?

    Here's another site which has some js code you might find useful:
    'Google is able to interpret JavaScript code and find links'. To avoid this we must use some encryption, even if it is elementary.
    JavaScript links invisible to search engines

    Can anyone help me make it open in the same window?
    Nope.
    Last edited by Mike-XS; 16 March, 2011 at 20:15 PM. Reason: your mum

  3. #3
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Japan/uk
    Posts
    699
    Thanks
    100
    Thanked 217 Times in 161 Posts
    To open in the same window you can use an onclick event for an HTML element and document.location in javascript.

    Not sure why you would want to hide a link from Google. Why not make it rel=nofollow. Maybe via the robots.txt file for javascript?

    Or detect a bot from the HTTP_USER_AGENT environment variable. Look for 'bot' in the string. Then make the link invisible or something.
    Article authors check out: Resource Box Wizard

  4. #4
    UncleP's Avatar
    UncleP is online now The perfect face for radio
    Join Date
    Nov 2009
    Location
    Blighty
    Posts
    162
    Thanks
    8
    Thanked 64 Times in 42 Posts
    Quote Originally Posted by ruffneck119 View Post
    I have looked all over no one has a solid script to hide a link using JS. I used this code but it will not open in the same window. Can anyone help me make it open in the same window? Or do you have your own code to hide links from Google?

    Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Begin
     
    function url() {
    hidden = open('http://www.url.com');
    }
     
    // End -->
    </script>
     
     
    <A HREF="javascript:url()" ><IMG SRC="image.jpg" border="0"></A>
    I'm a little curious as to why you'd want to hide links from google but couldn't you just put it in the robots.txt file so it doesn't crawl it? Or use a short link service. I can understand the need to 'cloak' links from the public tho' so those doing a mouse hover get a different url to actually clicking a link, to hide affiliate ID's for instance. JavaScript isn't needed for that, I have my own way if it's any use to you:
    Code:
    <a title="Click Here" href="http://www.google.com" onClick="this.href='http://www.yahoo.com'" target="_blank">Click Here</a>
    The above for instance would give a mouse over url for google but go to yahoo when clicked. If you use an affiliate ID then the plain url in the first link (for mouse over url) and the aff ID in the second link (to be visited). Take out the target="_blank" to open in the same window.

    It works for me and it's simple (I like simple) plus it works without JavaScript so it works if Java is off.

    Alternatively - you could link to a redirect page in a sub folder and hide the sub folder with robots.txt, that might work, then you could do a meta redirect (index.html) or have a php redirect (index.php).
    index.html redirect:
    Code:
    <html>
    <head>
    <meta http-equiv="refresh" content="0;url=http://www.domain.tld" />
    </head>
    <body>Loading...</body></html>
    index.php redirect:
    Code:
    <?php
    header('Location:http://www.domain.tld');
    ?>
    Or there's plan 'B' where you could redirect to a blank(ish) sub folder and have an .htaccess 301 redirect, but maybe I'm just thinking too much now.
    I Need Your New Proxies For My Lists, Please Give Generously:
    More Proxies & TopProxyList - Now With https (SSL) Support!

  5. #5
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Japan/uk
    Posts
    699
    Thanks
    100
    Thanked 217 Times in 161 Posts
    The above for instance would give a mouse over url for google but go to yahoo when clicked. If you use an affiliate ID then the plain url in the first link (for mouse over url) and the aff ID in the second link (to be visited). Take out the target="_blank" to open in the same window.
    I like that It should be great for affiliate links to say Amazon.

    Who cares about people with Javascript turned off? They won't buy anything anyway
    Article authors check out: Resource Box Wizard

  6. #6
    TopDogger's Avatar
    TopDogger is offline Über Hund
    Join Date
    Jan 2009
    Posts
    1,343
    Thanks
    201
    Thanked 575 Times in 403 Posts
    Quote Originally Posted by Andy101 View Post
    Who cares about people with Javascript turned off? They won't buy anything anyway
    It is not a matter of just having JavaScript turned off. If a user sets the security level to High in IE, active scripting is disabled, which includes JavaScript. A lot of users have JavaScript turned off and do not know it.
    You can have it fast, good or cheap. Pick any two.

Similar Threads

  1. Do you hide forums from guests ?
    By StephenM in forum Community Building
    Replies: 13
    Last Post: 8 July, 2010, 05:40 AM
  2. plugin to hide wordpress ?
    By SonnyCooL in forum Wordpress
    Replies: 7
    Last Post: 3 May, 2010, 13:45 PM
  3. Replies: 0
    Last Post: 17 February, 2010, 20:59 PM
  4. Tool to Hide IP's when visiting websites
    By Ascendancy in forum Promoting
    Replies: 1
    Last Post: 29 December, 2009, 21:46 PM
  5. How Not To Hide Text
    By imported_tirth in forum Promoting
    Replies: 0
    Last Post: 19 June, 2009, 16:57 PM

Tags for this Thread

Bookmarks

Posting Permissions

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