1. Get the string width
< Script >
Function Bounddim (oobject)
{
VaR Colltextarea = Document. All. Tags ( " Textarea " );
If (Colltextarea ! = Null )
{
VaR Otextrange = Oobject. createTextRange ();
If (Otextrange ! = Null )
{
Alert ("The width is \ n"+Otextrange. boundingwidth );
}
}
}
</ Script >
</ Head >
< Body >
< Textarea Cols = 100 Rows = 2 ID = Otextarea onclick = " Bounddim (this) " > Aaa </ Textarea >
2. halfwidth and fullwidth Conversion
How to deal with JS again
Function qjtobj (OBJ)
{
VaR Str = OBJ. value;
VaR result = "" ;
For (VAR I = 0 ; I < Str. length; I ++ )
{
If (Str. charcodeat (I) = 12288 )
{
Result+ =String. fromcharcode (Str. charcodeat (I)-12256);
Continue;
}
If (Str. charcodeat (I) > 65280 && Str. charcodeat (I) < 65375 )
Result + = String. fromcharcode (Str. charcodeat (I) - 65248 );
Else
Result + = String. fromcharcode (Str. charcodeat (I ));
}
OBJ. Value = Result;
}
3. How to Use JSON
The JSON structure is based on the following two points:
1. in different languages of the set of "name/value" pairs, It is understood as an object, record, structure (struct), Dictionary (dictionary ), hash table and keyed list
2. The ordered list of values is interpreted as an array in most languages)
JSON represents a JavaScript Object in a specific string. If a string with such a form is assigned to any JavaScript variable, the variable becomes an object reference, and this object is constructed by the string.
JSON format
· An object is a set of attributes and value pairs. An object starts with "{" and ends "}". Each attribute name and value is separated by a ":" prompt, and.
· An array is a set of ordered values. An array starts with "[", ends with "]", and values are separated.
· The value can be a string, number, true, false, or null in quotation marks, or an object or array. These structures can be nested.
· The definition of a string is basically the same as that of C or Java.
· The definition of numbers is also basically the same as that of C or Java.
VaR Userliststr = ' [{Name: "Michael", email: "17bity@gmail.com", homepage: "http://www.jialing.net /"}, '
+ ' {Name: "John", email: "john@gmail.com", homepage: "http://www.jobn.com /"}, '
+ ' {Name: "Peggy", email: "peggy@gmail.com", homepage: "http://www.peggy.com/"}] ' ;
Function Showuser ()
{
Eval ( " Userlist = " + Userliststr );
Alert (userlist [ 1 ]. Name );
}