Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Hiding links from bots using javascript question

  1. #1
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default Hiding links from bots using javascript question

    I need to make a link on my site undetectable for bots. I've just added rel="nofollow" to it, which should help.

    I just want to make sure that bots either do not see the link or totally ignore it. I tried to find something suitable online - no such luck.

    Any help will be appreciated.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I need to make a link on my site undetectable for bots. I've just added rel="nofollow" to it, which should help.
    Good bots will listen to your suggestions, and you can give more specific instructions in robot.txt (google that if needed). That includes bots like search engines, but does not include "bad bots". They don't care what you suggest.

    I just want to make sure that bots either do not see the link or totally ignore it. I tried to find something suitable online - no such luck.
    Javascript can't do this. It can make it harder to figure out, sort of like using emailATaddressDOTcom rather than email@address.com, but as with that, it's possible to program a bot that can figure it out. They don't usually parse Javascript, but "bad bots" might. So you may be making a lot of effort to block the bots that are already listening to your "nofollow" suggestion, while not blocking the others. I don't have any statistics on this, though.

    One simple way to do this would be to change the HREF of the link using Javascript. Maybe use onload and change the HREF of an <a> tag with a certain id. Simple enough. But again, that won't stop bots from looking in the JS to figure out what's going on.

    You can make it more difficult but not impossible. And you might lose some visitors along the way if it becomes hard for someone, for example, without Javascript.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by djr33 View Post
    One simple way to do this would be to change the HREF of the link using Javascript. Maybe use onload and change the HREF of an <a> tag with a certain id. Simple enough. But again, that won't stop bots from looking in the JS to figure out what's going on.
    Can you make it more practical? Give me an example, so that I could build on it. Thanks!

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Off the top of my head, something like this:

    <body onload="document.getElementById('mylink').href='http://my.new/link/';">

    <a href="something" id="mylink">LINK TEXT</a>


    And there are probably better ways to do this, as well as the fact that you really need to reconsider the logic behind it-- I'm not sure this is best for your site. But it's up to you.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,072
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    If you want to confuse even the most sophisticated bot (unless it actually runs the javascript code), not to mention yourself:

    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Obscure Links - Demo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <script type="text/javascript">
    function Zfunction(){var z=Zfunction,r,q=(r=arguments[0]).hash[z.q.f](z.q.rr,'');q&&z.q[q]&&z.z[q]&&(function(){r[z.e.p]=[z.z[q],z.q[q],'.',z.e.a].join('');})();}Zfunction.q={who:'doc',where:'page',rr:/#/,f:'replace'};Zfunction.e={a:'html',p:'href',g:document,t:function(){var l=Zfunction.e.g[Zfunction.e.w],ll=l.length;while(--ll>-1)Zfunction(l[ll]);},w:'links'};Zfunction.z={where:'some',who:'another'};
    </script>
    </head>
    <body>
    <a href="#where">Some Page</a><br>
    <a href="#who">Another Doc</a>
    <script type="text/javascript">
    Zfunction.e.t();
    </script>
    </body>
    </html>
    Click Here for a Demo.
    Last edited by jscheuer1; 03-24-2013 at 06:44 AM. Reason: add demo
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default

    John, I need something that people will still be able to click on. It's the bots that I am trying to deceive.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,072
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    That's what that is. I did say it would confuse you though, but it does work if javascript is enabled, and there's a script at the end you might have missed. Did you try the demo:

    http://home.comcast.net/~jscheuer1/s...scurelinks.htm

    The trick is the hash href. That becomes the key in:

    Code:
    Zfunction.z={where:'some',who:'another'}
    and:

    Code:
    Zfunction.q={who:'doc',where:'page',rr:/#/,f:'replace'}
    The extension is 'html' for both (gotten from Zfunction.e.a), but that can be changed if need be, even gotten via the key from Zfunction.e if the extensions are different. So a hash of "#who" becomes a link of "anotherdoc.html". Also, an extension is assumed. A hard coded . character is inserted between the filename and the extension. But that could also be changed if a folder or domain needs to be navigated to.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    qwikad.com (03-24-2013)

  9. #8
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default

    John, now I get it... and yes it is very confusing I will have to remove the html and the . other than that it should work.

  10. #9
    Join Date
    Oct 2012
    Posts
    157
    Thanks
    21
    Thanked 1 Time in 1 Post

    Default

    John, I've just added it to my site. It's doing what it's supposed to do.

    Did you design this code? It's genius.

  11. #10
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,072
    Thanks
    44
    Thanked 3,216 Times in 3,178 Posts
    Blog Entries
    12

    Default

    Yes, I just figured, "What would be the most confusing thing I could think of, something where the actual URL never appears and variables are not descriptive of what they do?"

    That's what I came up with. It's partly inspired by javascript compression methods like pack, that and my love of using objects for lookups.

    BTW, if you have an actual hash tag link on the page, it should still work normally as long as its value/name doesn't appear as a key in both the Zfunction.z and Zfunction.q objects.

    Oh, and you can make it even more obscure by making the scripts external.
    Last edited by jscheuer1; 03-24-2013 at 09:08 PM. Reason: add last line
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Similar Threads

  1. Are Dynamic Ajax links followed by bots?
    By easinewe in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 03-22-2010, 04:42 AM
  2. hiding the links on Ajaxtabscontent
    By orhun in forum Dynamic Drive scripts help
    Replies: 5
    Last Post: 12-01-2009, 10:34 AM
  3. bots (easy question)
    By james438 in forum PHP
    Replies: 3
    Last Post: 10-22-2008, 08:56 AM
  4. help regarding hiding links
    By rockstar2007 in forum Looking for such a script or service
    Replies: 5
    Last Post: 01-14-2007, 07:38 AM
  5. Hiding HV Menu using Javascript
    By tellic in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 11-21-2005, 08:27 AM

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
  •