Secure e-mail Link


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. function createJSMailLink($email) {
  2. $numArray = array();
  3.  
  4. for($a = 0; $a < strlen($email); $a++) {
  5. $numArray[] = ord($email{$a});
  6. }
  7.  
  8. $asciiString = implode(",", $numArray);
  9.  
  10. return <<<EOL
  11. <script type="text/javascript" charset="utf-8">
  12. var _ed = "";
  13. var _en = new Array({$asciiString});
  14.  
  15. for(var a = 0; a < _en.length; a++) {
  16. _ed += String.fromCharCode(_en[a]);
  17. }
  18.  
  19. document.write("<a href=\"" + "mailto:" + _ed + "\">" + _ed + "</a>");
  20. </script>
  21. EOL;
  22. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.