64、加密mail地址

64、加密mail地址

脚本说明:

把如下代码加入<body>区域中

<style type="text/css">

<!--

p,form,input,textarea {

   font-family: verdana, arial, helvetica, sans-serif;

   font-size: 12px;

}

-->

</style>

<script language="JavaScript">

<!--

function str2hex(s) {

   var a,b,d;

   var hexStr = '';

   for (var i=0; i < s.length; i++) {

      d = s.charCodeAt(i);

      a = d % 16;

      b = (d - a)/16;

      hexStr += '%' + "0123456789ABCDEF".charAt(b) + "0123456789ABCDEF".charAt(a);

   }

   return hexStr;

}

function encode() {

 

   var s0 = document.f1.str.value;

 

   var encod;

 

   document.f1.encoded.value = encod = str2hex(s0);

 

 

 

   s0 = s0.replace(/\@/,' at ');

 

   s0 = s0.replace(/\./g,' dot ');

 

 

 

   document.f1.all.value =

 

      '<a href="mailto:' + encod + '">yourTEXThere</a>' + '\r' +

 

      '<!-- ' + s0 + ' -->';

 

}

//-->

 

</script>

<form name="f1">

<p><font color="#CC0000">请输入一个正确的E-mail地址:</font><br>

<input type="text" name="str" size="60" onchange="encode()"></p>

<p><font color="#CC0000">加密后的代码为:</font><br>

<input type="text" name="encoded" size="60"></p>

<p><font color="#CC0000">完整的HTML代码</font><br>

<textarea rows="4" name="all" cols="60">

 

Write a comment

Comments: 0