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.


    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


    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 *


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

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

    main.js file *

    var iframe = document.querySelector(‘#iframe’);
    iframe.setAttribute(‘src’, ‘;);
    Though it removes the url from iframe, the javascripts dynamically add that.

    Hope it helps!

    • This reply was modified 9 months, 1 week 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.