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 details, seeCode.
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)
{
IntTMP=RND. Next (1, Len+ 1);
List. Add (input. substring (idx, TMP ));
Idx+ =TMP;
Len-=TMP;
}
ReturnList;
}
// encode string. ASCII: % XX format; Double Bytes: \ uxxxx format.
protected string encodestring ( string input)
{< br> stringbuilder output = New stringbuilder (input. length * 4 );
Foreach(CharCInInput)
{
IntCharvalue=(Int) C;
If (Charvalue > 255 )
{
Output. appendformat ( " \ U {0: X4} " , Charvalue );
}
Else
{
Output. appendformat ( " % {0: X2} " , Charvalue );
}
}
ReturnOutput. tostring ();
}
// Generate unique variable name.
Protected String Generatevarname ()
{
Random RND = New Random ();
String Output = (( Char )(( Int ) ' A ' + RND. Next ( 0 , 26 ). Tostring () + RND. Next ( 0 , 10 );
While (Vars. containskey (output ))
{
Output = (( Char )(( Int ) ' A ' + RND. Next ( 0 , 26 ). Tostring () + RND. Next ( 0 , 10 );
}
ReturnOutput;
}
Demo address: http://www.xianfen.net/Article148.aspx
Download Code: click here