Many enthusiastic bloggers leave their own Email addresses on their blogs to help others. To prevent spam, the email address is published in the form of an image or text with the @ symbol (at) or. This will inevitably cause inconvenience to others. When I browsed my brother-in-law's blog, I found that the email link was somewhat interesting. After a little research, I split the email address and encoded it. It seems that it is not an email address at all. In this way, the "email address Collector" can be crossed ". In the experiment, we found that mailto: can be identified by Outlook, while other mail clients are not tested.
It took a bag of cigarettes to write a small tool. The idea is: concatenate the email address into "mailto: youremail@domain.com? Subject = ", then the string is randomly split, encoded and assigned to the javascript variable. Add the javascript variables. The encoding method is to encode single-byte characters in the form of % XX, and (unicode) double-byte characters in the form of uXXXX. For specific implementation, see the code.
For the effect, see the announcement board.
How much code should I stick to? (Khan ...)
// Divide the string to some parts.
Protected List <string> PartString (string input)
{
List <string> list = new List <string> ();
Random rnd = new Random ();
Int len = input. Length;
Int idx = 0;
While (len> 0)
{
Int tmp = rnd. Next (1, len + 1 );
List. Add (input. Substring (idx, tmp ));
Idx + = tmp;
Len-= tmp;
}
Return list;
}
// Encode string. ASCII: % xx format; double bytes: uxxxx format.
Protected string EncodeString (string input)
{
StringBuilder output = new StringBuilder (input. Length * 4 );
Foreach (char c in input)
{
Int charValue = (int) c;
If (charValue> 255)
{
Output. AppendFormat ("\ u {0: x4}", charValue );
}
Else
{
Output. AppendFormat ("% {0: x2}", charValue );
}
}
Return output. ToString ();
}
// Generate unique variable name.
Protected string GenerateVarName ()
{
Random rnd = new Random ();
String output = (char) (int)