Common JavaScript code (2): javascript code
The article is from "PHP100 Chinese network"
Obtain the microseconds represented by the time
Var n1 = new Date ("2004-10-10". replace (/-/g, "\/"). getTime ()
Close Window?
Win. closed
Checkbox flat
<Input type = checkbox style = "position: absolute; clip: rect (5px 15px 15px 5px)"> <br>
Obtain selected content
Document. selection. createRange (). duplicate (). text
Automatic completion
<Input type = text autocomplete = on> enable this function
<Input type = text autocomplete = off> disable this function.
Window Maximization
<Body onload = "window. resizeTo (window. screen. width-4, window. screen. height-50); window. moveTo (-4,-4)">
No close button IE
Window. open ("aa.htm", "meizz", "fullscreen = 7 ");
Unified encoding/Decoding
Alert (decodeURIComponent (encodeURIComponent ("http: // hello. com? As = hehe ")))
EncodeURIComponent for ":", "/", ";" and "? "Also Encoding
Table row indication
<Tr onmouseover = "this. bgColor = '# f0f0f0'" onmouseout = "this. bgColor = '# ffff'">
1. Text Box focus
OnBlur: this event is generated when the input focus is lost.
OnFocus: this file is generated when the input gets the focus.
Onchange: this event is generated when the text value changes.
Onselect: this file is generated when the text is highlighted
<Input type = "text" value = "Guo Qiang" onfocus = "if (value = 'Guo Qiang ') {value =''} "onblur =" if
(Value = '') {value = 'Guo qi'}"> when you click, the text disappears and the text appears again when the focus is lost.
2. Special color of webpage buttons
<Input type = button name = "Submit1" value = "Guo Qiang" size = 10 class = s02
Style = "background-color: rgb (235,207, 22)">
3. color changes when the mouse moves out
<Input type = "submit" value = "find it" name = "B1" onMouseOut = this. style. color = "blue"
OnMouseOver = this. style. color = "red" class = "button">
4. Flat button
<Input type = submit value = subscription style = "border: 1px solid: #666666; height: 17px; width: 25pt; font-size: 9pt;
BACKGROUND-COLOR: # E8E8FF; color: #666666 "name =" submit ">
5. Button color change
<Input type = text name = "nick" style = "border: 1px solid #666666; font-size: 9pt; height: 17px;
BACKGROUND-COLOR: # F4F4FF; color: # ff6600 "size =" 15 "maxlength =" 16 ">
6. Flat input box
<Input type = "text" name = "T1" size = "20" style = "border-style: solid; border-width: 1">
7. Change the window to the specified size.
<Script>
Window. resizeTo (300,283 );
</Script>