Support » Fixing WordPress » Hide all external links using JavaScript

  • Hello,

    Is it possible to hide all external links from robots by replacing the link tag with span and clicking on it with a line of JavaScript. Basically, users can click on the link, but not be visible, especially for robots.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • You’re probably assuming bots like Googlebot cannot or does not parse JavaScript.

    Which would be patently wrong!

    Thread Starter moiablog

    (@moiablog)

    Yes, it would be wrong if I want the bots to read them.

    You can hide all external links using JavaScript from your site page. The style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”. document. getElementById(“element”).
    You can’t. If the URL isn’t in the HTML, how would the browser know where to get it?

    But there is a trick that can solve your purpose.

    HTML file *

    <html>
    <body>

    <iframe id=”iframe” src=””></iframe>

    <script src=”main.js”></script>

    </body>
    </html>
    main.js file *

    var iframe = document.querySelector(‘#iframe’);
    iframe.setAttribute(‘src’, ‘http://your-website.org/some-link-to-iframe/&#8217;);
    Though it removes the url from iframe, the javascripts dynamically add that.

    Hope it helps!

    • This reply was modified 1 year, 9 months ago by marshal09.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Hide all external links using JavaScript’ is closed to new replies.