JavaScript links invisible to search engines

Sometimes we want to put links in a page on which visitors can click but that for various reasons, we want not submit to search engines.

For example to avoid too many links to the same site so it is viewed as a farm link and got penalized.

JavaScript seems a good way to do that, but Google now is able to interpret the JavaScript code and find the links. To avoid this we must use some encryption, even if it is elementary.

Three JavaScript functions will be necessary.

JavaScript functions for character encoding


Returns the UNICODE code of a character.


var code = mystring.charCodeAt(5); 

Assign to the "code" variable the unicode value of the fifth character of the string "mystring".


Returns the character corresponding to a Unicode code.


var ch = String.fromCharCode(125); 

location.replace (url)

Load another page.

These functions will suffice for coding and decoding the URL.

URL encoding

This script adds the value 5 to each code of a given string in input. It displays the new chain encoded in an alert box where you can copy it and paste it into a variable.

function crypt()
var loc = document.getElementById("loc").value;
var nl = "";
for(var i = 0; i < loc.length; i++)
nl = nl + String.fromCharCode(loc.charCodeAt(i) + 5);

We place this script in a separate page that is displayed to encode URLs.

URL decoding

This script will be integrated into the page where is added the link:

function uncrypt(loc)
var nl = "";
for(var i = 0; i < loc.length; i++)
nl = nl + String.fromCharCode(loc.charCodeAt(i) - 5);
return nl;

The function will dynamically decode and returns the URL in clear.

The link itself is inserted into the page with code like this for a picture:

<img src="myimage.jpg" onClick="location.replace(uncrypt(loc))"  /> 

and for a textual lien:

<p onClick="location.replace(uncrypt(loc))" />Anchor</p>

You can also use the property replace:


But that disables the return to the original page.


This démos displays below the code for the URL you enter...

Enter an URL: