Posted By

iloveitaly on 01/05/09


Tagged

email javascript php link secure


Versions (?)

Who likes this?

6 people have marked this snippet as a favorite

brent-man
will_00
umang_nine
Nix
BrianCoyDesign
iloveitaly


Secure e-mail Link


 / Published in: PHP
 

  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  

You need to login to post a comment.