Tips on JavaScript, great recommendation

Source: Internet
Author: User

 
Event source object
Event. srcelement. tagname
Event. srcelement. Type
Capture and release
Event. srcelement. setcapture ();
Event. srcelement. releasecapture ();
Event buttons
Event. keycode
Event. shiftkey
Event. altkey
Event. ctrlkey
Event Return Value
Event. returnvalue
Mouse position
Event. x
Event. Y
Form Activity element
Document. activeelement
Bind event
Document. captureevents (event. keydown );
Access form elements
Document. All ("TXT"). Focus ();
Document. All ("TXT"). Select ();
Form commands
Document.exe ccommand
Form cookie
Document. Cookie
Menu events
Document. oncontextmenu
Create Element
Document. createelement ("span ");
Obtain the element with the mouse:
Document. elementfrompoint (event. X, event. Y). tagname = "TD
Document. elementfrompoint (event. X, event. Y). appendchild (MS)
Form Image
Document. Images [Index]
Form event binding
Document. onmousedown = scrollwindow;
Element
Document. Form. elements [Index]
Object binding event
Document. All. XXX. detachevent ('onclick', );
Number of plug-ins
Navigator. plugins
Variable type
Typeof ($ js_libpath) = "undefined"
Drop-down list
Drop-down box. Options [Index]
Drop-down box. Options. Length
Search for objects
Document. getelementsbyname ("R1 ");
Document. getelementbyid (ID );
Timing
Timer = setinterval ('rollwindow () ', delay );
Clearinterval (timer );
Uncode Encoding
Escape (), Unescape
Parent object
OBJ. parentelement (DHTML)
OBJ. parentnode (DOM)
Exchange table rows
Tableid. moverow (2, 1)
Replace CSS
Document.all.css S. href = "a.css ";
Side by side
Display: inline
Hide focus
Hidefocus = true
Line feed Based on Width
Style = "word-break: Break-all"
Auto refresh
<Metahttp-equiv = "refresh" content = "8; url = http://c98.yeah.net">
Simple email
<Ahref = "mailto: aaa@bbb.com? Subject = CCC & Body = xxxyyy ">
Quickly go to location
OBJ. scrollintoview (true)
Anchor
<Aname = "first">
<Ahref = "# First"> anchors </a>
Webpage Transfer Parameters
Location. Search ();
Editable
OBJ. contenteditable = true
Run the menu command
Obj.exe ccommand
Double-byte characters
/[^/X00-/xFF]/
Chinese characters
/[/U4e00-/u9fa5]/
Automatically wrap an English string out of the table width
Word-wrap: Break-word; Word-break: Break-all;
Transparent background
<Iframesrc = "1.htm" width = 300 Height = 180 allowtransparency> </iframe>
Get style content
Obj.style.css text
HTML Tag
Document.doc umentelement. innerhtml
First style label
Document. stylesheets [0]
The first style in the style label
Document. stylesheets [0]. Rules [0]
When you click an empty link, the page is often reset to the top.
<Ahref = "javascript: function ()"> word </a>
Previous webpage Source
ASP:
Request. servervariables ("http_referer ")
Javascript:
Document. referrer
Release memory
Collectgarbage ();
Disable right-click
Document. oncontextmenu = function () {returnfalse ;}
Save prohibited
<NoScript> <iframesrc = "*. htm"> </iframe> </NoScript>
Disable <bodyoncontextmenu = "returnfalse" ondragstart = "returnfalse" onselectstart = "returnfalse" onselect = "document. selection. empty () "oncopy =" document. selection. empty () "onbeforecopy =" returnfalse "onmouseup =" document. selection. empty ()>
Disable pasting
<Inputtype = textonpaste = "returnfalse">
Address bar icon
<Linkrel = "shortcuticon" href = "favicon. ICO">
It is recommended that the favicon. ICO name remain the same as 16 colors for 16*16. Put it in the root directory of the virtual directory.
Add to favorites bar icon
<Linkrel = "bookmark" href = "favicon. ICO">
View Source Code
<Inputtype = buttonvalue = view the webpage source code onclick = "window. Location = 'view-Source: '+ 'HTTP: // www.csdn.net/'">
Disable Input Method
<Inputstyle = "ime-mode: Disabled">
Automatically select all
<Inputtype = textname = text1value = "123" onfocus = "This. Select ()">
Enter to move the cursor to the next input box
<Inputonkeydown = "If (event. keycode = 13) event. keycode = 9">
Default Value of the text box
<Inputtype = textvalue = "123" onfocus = "alert (this. defaultvalue)">
Title line feed
OBJ. Title = "123 sdfs"
Obtain the microseconds represented by the time
Varn1 = newdate ("2004-10-10". Replace (/-/g, "//"). gettime ()
Close Window?
Win. Closed
Checkbox flat
<Inputtype = checkboxstyle = "position: absolute; clip: rect (5px15px15px5px)"> <br>
Obtain selected content
Document. selection. createRange (). Duplicate (). Text
Automatic completion
<Inputtype = textautocomplete = on> enable this function.
<Inputtype = textautocomplete = off> disable this function.
Window Maximization
<Bodyonload = "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
<Tronmouseover = "This. bgcolor = '# f0f0f0'" onmouseout = "This. bgcolor = '# ffff'">

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.