email地址加密代碼:
<code><meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ /></code>
<style type=”text/css”><!–
body { font-size: 12px; }
–></style><script type=”text/javascript” language=”javascript”>// <![CDATA[
var email = "[email protected]";
function getEmail(email)
{
var r = "";
for (i=0;i<email.length;i++)
{
r += "&#" + email.charCodeAt(i);
}
return r;
}
function setClipboard(id)
{
var tb = document.getElementById(id);
var copytext = tb.value;
if (copytext!="")
{
if (window.clipboardData)
{
window.clipboardData.setData("Text", copytext);
alert("已復制到剪貼板。");
}
else if (window.netscape)
{
setClipboardNetscape(copytext);
alert("已復制到剪貼板。");
}
}
return false;
}
function setClipboardNetscape(text){
var url = [
'data:text/html;charset=utf-8;base64,PGJvZHk+PC9ib2',
'R5PjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4KKGZ1',
'bmN0aW9uKGVuY29kZWQpe3ZhciBzd2ZfZGF0YSA9IFsKICdkYX',
'RhOmFwcGxpY2F0aW9uL3gtc2hvY2t3YXZlLWZsYXNoO2Jhc2U2',
'NCxRMWRUQjJ3JywKICdBQUFCNG5EUGdZbGpBd01qSTRNejAlMk',
'YlMkY5JTJGZTJaZkJnYUdhV3dNRE1uNUthJywKICdrTU10TjRH',
'ZGdaZ1NJTXdaWEZKYW01UUFFJTJCQm9iaTFCTG5uTXlDcFB6RW',
'9oU0dJJywKICdQRnAlMkZBeHNEREJRa3BGWkRGUUZGQ2d1eVM4',
'QXlqSTRBRVVCaXkwVndBJTNEJTNEJwpdLmpvaW4oIiIpOwpkb2',
'N1bWVudC5ib2R5LmlubmVySFRNTCA9IFsKICc8ZW1iZWQgc3Jj',
'PSInLHN3Zl9kYXRhLCciICcsCiAnRmxhc2hWYXJzPSJjb2RlPS',
'csZW5jb2RlZCwnIj4nLAogJzwvZW1iZWQ+JwpdLmpvaW4oIiIp',
'Owp9KSgi',
base64encode( encodeURIComponent(text) + '")</'+'script>')
].join(“”);
var tmp = document.createElement(“div”);
tmp.innerHTML = [
'<iframe src="',url,'"' ,' width="0" height="0">'
,'</iframe>'
].join(“”);
with(tmp.style){
position =”absolute”;
left = “-10px”;
top = “-10px”;
visibility = “hidden”;
};
document.body.appendChild(tmp);
setTimeout(function(){document.body.removeChild(tmp)},1000);
function base64encode(str){
var Chars = “ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/”.split(“”);
var c1, c2, c3;
var buf = [];
var len = str.length;
var i = 0;
while(i < len){ c1 = str.charCodeAt(i) & 0xff; c2 = str.charCodeAt(i+1); c3 = str.charCodeAt(i+2); buf.push(Chars[(c1 >> 2)]);
if(i+1 == len){
buf.push(Chars[(c1 & 0x3) << 4],”==”);
break;
}
buf.push(Chars[((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4)]);
if(i+2 == len){
buf.push(Chars[(c2 & 0xF) << 2],”=”);
break;
}
buf.push(
Chars[((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6)],
Chars[(c3 & 0x3F)]
);
i+=3;
}
return buf.join(“”)
}
}
// ]]></script>
<strong>Email地址加密</strong>
Email:
<input id=”email” type=”hidden” name=”email” size=”50″ value=”[email protected]” />
<input onclick=”document.getElementById(‘export’).value=getEmail(document.getElementById(‘email’).value)” type=”button” name=”Submit” value=” 加 密 ” />
<input onclick=”document.getElementById(‘preview’).innerHTML=getEmail(document.getElementById(‘email’).value)” type=”button” name=”Submit2″ value=” 點擊查看Email ” /> <span id=”preview” style=”color: #ff0000;”> </span>
結 果:
<input id=”export” type=”text” name=”export” size=”76″ />