Home : Internet : JavaScript : Text : Hiding

Hide Text From Robots

Using JavaScript it is possible to make text on a web page visible to real people but not to automated robots such as search engines, email harvesters, etc. Be aware that users who don't have JavaScript enabled will see nothing.

There is only one simple step: Use the document write method to write your text to the page. Copy the code below into your HTML code where you want the text to appear:

<script language="JavaScript" type="text/JavaScript">
document.write('Enter your text here');

You can add HTML formatting to the text within the JavaScript code, but be careful about including special characters. You could also add formatting tags before and after the JavaScript tags, so they don't need to be part of the script.

For more information see the document write method.

How it Works

Automated robots scans web pages looking for strings of text. They don't generally try to execute JavaScript — they just ignore it — so everything with the script is effectively invisible. This will work for most robots in most situations, but it is not 100% guaranteed.

When a real person with a JavaScript-enabled browser views the page, the script will run and the specified text will appear on the page.