Title: Hide all external links using JavaScript
Last modified: February 9, 2022

---

# Hide all external links using JavaScript

 *  [moiablog](https://wordpress.org/support/users/moiablog/)
 * (@moiablog)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/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](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fhide-all-external-links-using-javascript%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [George Appiah](https://wordpress.org/support/users/gappiah/)
 * (@gappiah)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/hide-all-external-links-using-javascript/#post-15346111)
 * You’re _probably_ assuming bots like Googlebot cannot or does not parse JavaScript.
 * Which would be patently wrong!
 *  Thread Starter [moiablog](https://wordpress.org/support/users/moiablog/)
 * (@moiablog)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/hide-all-external-links-using-javascript/#post-15346380)
 * Yes, it would be wrong if I want the bots to read them.
 *  [marshal09](https://wordpress.org/support/users/marshal09/)
 * (@marshal09)
 * [3 years, 11 months ago](https://wordpress.org/support/topic/hide-all-external-links-using-javascript/#post-15755447)
 * You can hide all external links using JavaScript from your [site](https://inloggenhulp.com/)
   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](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 3 years, 11 months ago by [marshal09](https://wordpress.org/support/users/marshal09/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Hide all external links using JavaScript’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [marshal09](https://wordpress.org/support/users/marshal09/)
 * Last activity: [3 years, 11 months ago](https://wordpress.org/support/topic/hide-all-external-links-using-javascript/#post-15755447)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
