1. Dayin ()
Purpose: You can create a page and print the content with the ID of Dayin to solve the problem of printing part of the content on a page.
Usage: The content to be printed is included by <span id = "Dayin"> </span>, and then an event is defined in a button.
<Input type = "button" onclick = "Dayin ()" value = "print">
CopyCode The Code is as follows: function Dayin ()
{
VaR code = "<body onload = Window. Print ()>"
Code + = Document. All. Dayin. innerhtml;
Code = code. touppercase ();
Code = code. Replace (/<A [^>] *> Delete <\/A>/GI ,"");
Code = code. tolowercase ();
VaR newwin = Window. Open ('','','');
Newwin. Opener = NULL;
Newwin.doc ument. Write (CODE );
Newwin.doc ument. Close ();
}
Code = code. Replace (/<A [^>] *> Delete <\/A>/GI ,"");
Is to filter out all the deleted connections in the content
2. isnumber (ST)
Function: Determines whether the st variable is composed of numbers (including negative numbers and decimals). If true is returned, false is returned.Copy codeThe Code is as follows: function isnumber (ST)
{
VaR letters = "1234567890 -.";
VaR I;
VaR C;
If (St. charat (0) = '.')
Return false;
If (St. charat (0) = '-' & St. charat (1) = '.')
Return false;
If (St. charat (St. Length-1) = '-')
Return false;
For (I = 0; I <st. length; I ++)
{
C = ST. charat (I );
If (letters. indexof (c) <0)
Return false;
}
Return true;
}
3. createcookie (name, value, days)
Purpose: Create a cookie with the name, value as values, and validity period as days. It can also be modified.Copy codeThe Code is as follows: function createcookie (name, value, days ){
VaR expires = "";
If (days ){
VaR date = new date ();
Date. settime (date. gettime () + (days * 24x60*60*1000 ));
Expires = "; expires =" + date. togmtstring ();
};
Document. Cookie = Name + "=" + value + expires + "; Path = /";
};
4. readcookie (name)
Purpose: Read the cookie value based on the name. If no value exists, null is returned.Copy codeThe Code is as follows: function readcookie (name ){
VaR nameeq = Name + "= ";
VaR CA = Document. Cookie. Split (';');
For (VAR I = 0; I <ca. length; I ++ ){
VaR c = Ca [I];
While (C. charat (0) = '') C = C. substring (1, C. Length );
If (C. indexof (nameeq) = 0) return C. substring (nameeq. length, C. Length );
};
Return NULL;
};
5. Request (ST)
Purpose: Get the value of a parameter in the address bar of the browser (not perfect. For example, % 20 will be obtained if there is space, but Chinese is supported)Copy codeThe Code is as follows: function request (ST ){
VaR USTR = Document. Location. search;
VaR intpos = USTR. indexof ("? ");
VaR strright = USTR. substr (intpos + 1 );
VaR arrtmp = strright. Split ("% 26 ");
For (VAR I = 0; I <arrtmp. length; I ++)
{
VaR arrtemp = arrtmp [I]. Split ("= ");
If (arrtemp [0]. touppercase () = ST. touppercase () return arrtemp [1];
}
Return "";
}
6. hideobject (OBJ)
Purpose: Hide OBJCopy codeThe Code is as follows: function hideobject (OBJ ){
OBJ. style. Display = "NONE ";
}
7. showobject (OBJ)
Purpose: Display OBJCopy codeThe Code is as follows: function showobject (OBJ ){
OBJ. style. Display = "Block ";
}