Copy codeThe Code is as follows :/*
* Contains jquery-1.3.2.min.js
*/
Document. write ("<script language = 'javascript 'src = 'js/jquery-1.3.2.min.js '> </script> ");
/*
* Public Parameters
*/
Var hostUrl = 'HTTP: // '+ window. location. host; // obtain the website host Header
/*
* Horizontal center left Value
*/
Function HorCenter (x ){
Return (document.doc umentElement. clientWidth-x)/2;
}
/*
* Vertical center top Value
*/
Function VerCenter (y ){
Return (document.doc umentElement. clientHeight-y)/2+document.doc umentElement. scrollTop;
}
/*
* Delete spaces between the left and right sides.
*/
Function Trim (str ){
Return str. replace (/(^ \ s *) | (\ s * $)/g ,"");
}
/*
* Determines the mailbox. true/false is returned.
*/
Function IsEmail (email ){
Var Expression =/\ w + ([-+. '] \ w +) * @ \ w + ([-.] \ w + )*\. \ w ([-.] \ w + )*/;
Var objExp = new RegExp (Expression );
Return objExp. test (email );
}
/*
* Determines the user name. true/false is returned.
*/
Function IsUser (user ){
Var Expression =/^ (?! _)(?!. *? _ $) (\ W | [\ u4E00-\ u9FA5]) * $/; // only a combination of numbers, Chinese characters, letters, and underscores is allowed. Underlines cannot start or end
Var objExp = new RegExp (Expression );
Return objExp. test (user );
}
/*
* Determine the mobile phone number
*/
Function IsMobile (mobile ){
Var Expression =/^ 1 [3458] {1} [0-9] {9} $ /;
Var objExp = new RegExp (Expression );
Return objExp. test (mobile );
}
/*
* Determines a non-negative integer. true/false is returned.
*/
Function IsInt (intval ){
Var Expression =/^ \ d + $ /;
Var objExp = new RegExp (Expression );
Return objExp. test (intval );
}
/*
* Returns true/false to determine the number.
*/
Function IsNum (num ){
Return! IsNaN (num );
}
/*
* Returns true/false to determine the renminbi (money ).
*/
Function IsMoney (money ){
Var Expression =/^ ([1-9] \ d + | 0 )\. \ d {2} | ([1-9] \ d + | 0) $ /;
Var objExp = new RegExp (Expression );
Return objExp. test (money );
}
/*
* Calculate the length of a string. The length must be two Chinese characters and one English digit.
*/
Function GetByteLen (sChars ){
Return sChars. replace (/[^ \ x00-\ xff]/g, "xx"). length;
}
/*
* Restrict the maximum input string
*/
Function GetByteVal (sSource, iLen ){
If (sSource. replace (/[^ \ x00-\ xff]/g, "xx"). length <= iLen)
{
Return sSource;
}
Else
{
Var str = "";
Var l = 0;
Var schar;
For (var I = 0; schar = sSource. charAt (I); I ++)
{
Str + = schar;
L + = (schar. match (/[^ \ x00-\ xff]/)! = Null? 2: 1 );
If (l> = iLen)
{
Break;
}
}
Return str;
}
}
/*
* Write cookie
*/
Function SetCookie (name, value)
{
Var argv = SetCookie. arguments;
Var argc = SetCookie. arguments. length;
Var expires = (2 <argc )? Argv [2]: null;
Var path = (3 <argc )? Argv [3]: null;
Var domain = (4 <argc )? Argv [4]: null;
Var secure = (5 <argc )? Argv [5]: false;
Document. cookie = name + "=" + escape (value) + (expires = null )? "" :( "; Expires =" + expires. toGMTString () + (path = null )? "" :( "; Path =" + path) + (domain = null )? "" :( "; Domain =" + domain) + (secure = true )? "; Secure ":"");
}
/*
* Get cookie
*/
Function GetCookie (name ){
Var search = name + "= ";
Var returnvalue = "";
If (document. cookie. length> 0)
{
Offset = document. cookie. indexOf (search );
If (offset! =-1)
{
Offset + = search. length;
End = document. cookie. indexOf (";", offset );
If (end =-1)
End = document. cookie. length;
Returnvalue = unescape (document. cookie. substring (offset, end ));
}
}
Return returnvalue;
}
/*
* Select and delete all checkpoints.
*
* Reference
* <Input name = "chkbox" type = "checkbox" onclick = "checkAll (this, 'form1 ')"/>
* <Input name = "chkbox" type = "checkbox" value = "" class = "chk"/>
*/
Function CheckAll (obj, objForm ){
If (obj. checked = true ){
$ ('#' + ObjForm + 'input: checkbox. chk'). each (function (){
This. checked = 'checked ';
});
}
Else {
$ ('#' + ObjForm + 'input: checkbox. chk'). each (function (){
This. checked = '';
});
}
}
/*
* Supports copying from multiple browsers.
*/
Function CopyValue (strValue ){
If (IsIE ())
{
ClipboardData. setData ("Text", strValue );
Alert ("successfully copied ");
}
Else
{
Copy (strValue );
Alert ("successfully copied ");
}
}
/*
* Judge IE browser
*/
Function IsIE (number ){
If (typeof (number )! = Number)
{
Return !! Document. all;
}
}