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

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
    209
    Thanks
    30
    Thanked 109 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
    Kanazawa
    Posts
    1,266
    Thanks
    173
    Thanked 305 Times in 232 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.

  4. #4
    UncleP's Avatar
    UncleP is offline The perfect face for radio
    Join Date
    Nov 2009
    Location
    Blighty
    Posts
    218
    Thanks
    20
    Thanked 91 Times in 61 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.
    If I can't be a good example, I'll just have to be a terrible warning...

  5. #5
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,266
    Thanks
    173
    Thanked 305 Times in 232 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

  6. #6
    TopDogger's Avatar
    TopDogger is online now Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,079
    Thanks
    347
    Thanked 914 Times in 698 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.
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


  7. #7
    xxcorrosionxx's Avatar
    xxcorrosionxx is offline Newbie Net Builder
    Join Date
    Oct 2012
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post
    Can i point something out? You cannot hide links using "scripts", its impossible. Well look, you could mask them, but decrypting the link would be easy. Hiding them using a database is however possible

  8. #8
    Andy101's Avatar
    Andy101 is offline Code Otaku
    Join Date
    Aug 2009
    Location
    Kanazawa
    Posts
    1,266
    Thanks
    173
    Thanked 305 Times in 232 Posts
    Hiding them using a database is however possible
    A database is simply a store of data with an engine to manipulate the data via server-side scripts such as PHP.

    Of course, you can completely hide links using PHP where the links are simply not displayed according to what kind of visitor is detected.

    p.s. If a user sets the security level to High in IE I don't think they would buy anything because they would fear using their credit card online.

  9. #9
    TopDogger's Avatar
    TopDogger is online now Über Hund
    Join Date
    Jan 2009
    Location
    Hellfire, AZ
    Posts
    3,079
    Thanks
    347
    Thanked 914 Times in 698 Posts
    Quote Originally Posted by xxcorrosionxx View Post
    Hiding them using a database is however possible
    If you just want to block the links from spiders for affiliate marketing, Matt Cutts recommends putting the links in a separate script and blocking the script using the robots.txt file. Here is one way of doing that without using a database.

    Redirect Script for Affiliate Marketing - Click Script


    Quote Originally Posted by Andy101 View Post
    p.s. If a user sets the security level to High in IE I don't think they would buy anything because they would fear using their credit card online.
    Microsoft has recommended setting security to High several times in the past whenever some of their numerous JavaScript-related security bugs became public. It does disable some features on a lot of sites, especially if the sites use JQuery or Ajax. Here is one that they just issued on October 8, 2012. There have been dozens of these advisories over the past five years.

    Microsoft Security Advisory (2755801)
    "Democracy is two wolves and a lamb voting on what to have for lunch. Liberty is a well-armed lamb contesting the vote." -- Benjamin Franklin


  10. #10
    xxcorrosionxx's Avatar
    xxcorrosionxx is offline Newbie Net Builder
    Join Date
    Oct 2012
    Posts
    30
    Thanks
    0
    Thanked 1 Time in 1 Post
    Who the hell uses IE anymore? Lol about 5 different web browsers came out then that default version. Lol, firefox still wins over everythings.

Page 1 of 2 12 LastLast

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
  •