Saturday, August 30, 2014

Hiding emails posted on websites from spambots

At the end of my last post, I've posted my email for you to send your web development/ coding questions and inquiries:





The nice thing about it? You can see it but spambots can't! That means that the email address posted won't be flooded with pesky spams or other what-have-you.

So how did I do it? I simply applied the steps discussed in http://www.websitecodetutorials.com/code/javascript/graceful-degradation-mailto-email-address-obfuscation-tutorial.php to show my email at the browser and hide it from the spambots at the same time.

Now, let's go over the steps to apply for an anonymous email, john.doe@nowhere.com

First, we decide that the email link will be <a href="mailto:john.doe@nowhere.com">email me</a>. On the link http://www.wmtips.com/tools/html-obfuscator/, do the following:

  1. Copy/ paste <a href="mailto:john.doe@nowhere.com">email me</a> on the input box provided
  2. Click Get obfuscated code button
  3. The resulting code is displayed. Select the code and copy. You may click Select All link.
  4. View the generated code


Enter the CSS below on the web page where the email link will appear:

<style>
#method1 b {
display:none;
}

Going back to the generated obfuscated code, copy/paste it on the bottom end of web page. This may be placed right before the </body> tag.

Next, we put in the HTML for the email link. From the CSS, we see that anything placed inside the <b> tag within any element tag of ID 'method1' will not be displayed at all. Therefore, we can write HTML with such tags to confuse spambots crawling our website.

The HTML, <p><span id="method1">joh<b>r</b>ndoe@g<b>wma</b>mail.com</span></p>, will only be seen by Spambot as it is, but will output on browser as:
The obfuscated code will show the email link below the email address:





The full HTML

<html>
  <head>
    <title>Hiding Email from Spambots</title>
 <style>
  #method1 b {
  display:none;
  }
 </style>
  </head>
  <body>
  <p><span id="method1">joh<b>r</b>ndoe@no<b>wma</b>where.com</span></p>
  <script type="text/javascript">
 <!--
 var s="=b!isfg>#nbjmup;kpio/epfAopxifsf/dpn#?fnbjm!nf=0b?";
 m=""; for (i=0; i<s.length; i++) m+=String.fromCharCode(s.charCodeAt(i)-1); document.write(m);
 //-->
 </script>
 <noscript>
 You must enable JavaScript to see this text.
 </noscript>
  </body>
</html>
Got web development stuffs you want me to help you out? Email it to me at junrahsy.dolor@gwmamail.com and I'll be more than happy to blog about it with my inputs.

No comments:

Post a Comment