Invisible JavaScript links for search engines
Sometimes you want to post links on the page that visitors can click on, but for various reasons you don't want to introduce the search engine.
In order, for example, to prevent too many links to the same site from being mistaken for a farm of links and from harming the site on which they are contained.
JavaScript looks like a good way to do this, but Google is now able to interpret JavaScript code and find links in it. To avoid this, you need to use encryption, even if it is elementary.
Three JavaScript functions are required.
JavaScript Character Encoding Features
charCodeAt
Returns the UNICODE code of a character.
Example:
var code = machaine.charCodeAt(5);
Assigns to the variable encodes the Unicode value of the fifth character of the "machine" string.
fromCharCode
Returns the character corresponding to the UNICODE code.
Example:
var ch = String.fromCharCode(125);
location .replace (url)
Loads another page.
These functions will be enough to encode and decrypt the URL.
URL encoding
This script adds 5 to each code in a given line. It displays a new encoded string in the warning field, where you can copy it to 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);
alert(nl);
}
This script is placed on the page, with the exception of URLs displayed for encoding.
URL decryption
This script will be embedded in the page where the link is located:
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 decrypts and dynamically returns a simple URL.
The link itself is inserted into the page with the following code for the image:
<img src="monimage.jpg" onClick="self.location=uncrypt(loc)" />
and for a text link:
<p onClick="self.location=uncrypt(loc)" />Ancre</p>
You can also use the property:
location.replace(uncrypt(loc))
But this disables returning to the start page.
Display
This demo below shows the code for the URL you give...
Enter URL: