![]() | ![]() |
The only problem with the JavaScript e-mail obfuscating script presented on this site already is that you have to embed JavaScript into your web page for it to work. I've been looking for an alternative and I have found one in a php script that obfuscates your email address by re-shuffling and then uses plain CSS to make it apear in the web page as a normal email address that people can cut and paste though the underlying code is obfuscated and your email cannot be harvested by automated email harvesters.
The Celtnet email encoding service is completely free and is provided as a service to users of this site., It will ensure that your email address is protected from harvesting by robots and software email trawling programs.
Simply enter your email address and press the encode address button to generate an encrypted e-mail for that address:
To use the code generated simply copy and paste into your own web page but remember to add the CSS code to the page or all you will see is gibberish! An example of what your encoded email looks like to a visitor to your site is given beneath the code that's been generated.
Remember, however, that if you want to print out the email address (and for it to actually look like a real email address in your browser) you will need to add the following CSS code either to your CSS file or to your HTML page (or HTML-based eMail). I actually add this to the HTML page itself just before the end of the </head> tag:
<style type="text/css">
.mstag{position:absolute; font-family:monospace;margin:0.45em;background-color:#fcc};
</style>
You now have everything you need to deploy the php code on your own website. But if you don't want to deploy the entire code you can use the form below to generate the code that will allow you to generate code to obfuscate your own e-mails.
The code for generating the obfuscated email address is based on that of Daniel Hjerth whith a few changes of my own. This code is given below:
function mailshuffle( $mail ) {
$output = array();
$element = "span";
$spacing = 'round($x/1.75, 2)';
$class = "mstag";
$spacing_attribute = "left";
$spacing_type = "em";
for ($x=0; $x<strlen($mail); $x++)
{
eval('$i = '. $spacing . ";");
$output[] =
"<{$element} class='{$class}' style='{$spacing_attribute}:{$i}{$spacing_type};'>".htmlentities($mail{$x})."</{$element}>";
}
if(function_exists("shuffle_variable"))
{
shuffle_variable(&$output);
}
else
{
mt_srand( (double) microtime() * pow(10,5) );
$array_size = count($output);
for($x=0; $x<$array_size; $x++)
{
$n = mt_rand(0, $array_size - 1);
$p = $output[$n];
$output[$n] = $output[$i];
$output[$i] = $p;
}
}
return "<div style='position:absolute;'>".implode("",$output)."</div>";
}
To get this function to work you will need to call it with something like: echo "<p>".mailshuffle($Email)."</p><br/><br/>"; (where $Email is the email you want to obfuscate) which both calls the function with your email address and prints the result to your web page.
Also, remember that you will need to add the following CSS code
<style type="text/css">
.mstag{position:absolute; font-family:monospace;margin:0.45em;background-color:#fcc};
</style>
to any web page where you want the code to disply as an email address.
Not found what you're looking for? Search the web: