Created
November 28, 2012 05:59
-
-
Save CatTail/4159310 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// html email code transformation | |
// See http://www.awflasher.com/jsmail | |
function HtmlEncode( s ) | |
{ | |
var result = ""; | |
for (var j = 0; j < s.length; j++ ) { | |
// Encode 25% of characters | |
if (Math.random() < 0.25 | |
|| s.charAt(j) == ':' | |
|| s.charAt(j) == '@' | |
|| s.charAt(j) == '.') { | |
var charCode = s.charCodeAt(j); | |
result += "&#"; | |
result += charCode; | |
result += ";" | |
} else { | |
result += s.charAt(j); | |
} | |
} | |
return result; | |
} | |
function UrlEncode( s ) | |
{ | |
var HEX = "0123456789ABCDEF"; | |
var encoded = ""; | |
for (var i = 0; i < s.length; i++ ) { | |
// Encode 25% of characters | |
if (Math.random() < 0.25) { | |
var charCode = s.charCodeAt(i); | |
encoded += "%"; | |
encoded += HEX.charAt((charCode >> 4) & 0xF); | |
encoded += HEX.charAt(charCode & 0xF); | |
} else { | |
encoded += s.charAt(i); | |
} | |
} // for | |
return encoded; | |
} | |
function Obfuscate() | |
{ | |
var plaintext = document.TheForm.F1.value; | |
var result = "<a href='"; | |
result += HtmlEncode("mailto:" + UrlEncode(plaintext) ) | |
result += "'>" | |
result += HtmlEncode(plaintext) | |
result += "</a>"; | |
document.TheForm.F2.value = result; | |
if (document.all) { | |
document.all.RESULT.innerHTML = "æç»ææ: " + result; | |
} else { | |
document.getElementById("result").innerHTML = "æç»ææ: " + result + " ï¼æ³¨æè§å¯ç¶ææ ï¼è¿å¯æ¯æ åçmailtoé¾æ¥å¦ï¼"; | |
} | |
return false; /* Privacy note: returning false prevents the browser from posting your email address! */ | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When you put some string together, you'd better do like this:
str = [];
str.push(str1);
str.push(str2);
str = str.join('');