Some of the JavaScript techniques you can refer to in the process of making Web pages

Source: Internet
Author: User
Tags object empty html tags key return tagname window root directory
javascript| Reference | process | Web Page Event Source Object
Event.srcElement.tagName
Event.srcElement.type
Capture release
Event.srcElement.setCapture ();
Event.srcElement.releaseCapture ();
Event key
Event.keycode
Event.shiftkey
Event.altkey
Event.ctrlkey
Event return value
Event.returnvalue
Mouse position
Event.x
Event.y
Form activity elements
Document.activeelement
Binding events
Document.captureevents (Event.keydown);
accessing form elements
document.all ("TXT"). focus ();
document.all ("TXT"). Select ();
Form command
Document.execcommand
form cookies
Document.cookie
Menu Events
Document.oncontextmenu
Creating elements
Document.createelement ("SPAN");
To get elements from the mouse:
Document.elementfrompoint (EVENT.X,EVENT.Y). tagname== "TD
Document.elementfrompoint (EVENT.X,EVENT.Y). appendchild (MS)
Form picture
document.images[Index]
Form Event Bindings
Document.onmousedown=scrollwindow;
Elements
Document. Forms. Elements[index]
Object Binding Events
Document.all.xxx.detachEvent (' onclick ', a);
Number of Plug-ins
Navigator.plugins
Take variable type
typeof ($js _libpath) = = "Undefined"
Drop down box
Dropdown box. options[Index]
Drop-down box. Options.length
Finding objects
Document.getelementsbyname ("R1");
document.getElementById (ID);
Timing
Timer=setinterval (' ScrollWindow () ', delay);
Clearinterval (timer);
Uncode Code
Escape (), unescape
Parent object
Obj.parentelement (DHTML)
Obj.parentnode (DOM)
exchange table Rows
Tableid.moverow (2,1)
Replace CSS
Document.all.csss.href = "A.css";
Show side
Display:inline
Hide Focus
Hidefocus=true
Wrap line by width
Style= "Word-break:break-all"
Auto Refresh
<meta http-equiv= "Refresh" content= "8; Url=http://www.webjx.com ">
Simple Mail
<a href= "Mailto:aaa@bbb.com?subject=ccc&body=xxxyyy" >
Quick go to position
Obj.scrollintoview (True)
Anchor
<a name= "a" >
<a href= "#first" >anchors</a>
Page Pass Parameters
Location.search ();
Can be edited
Obj.contenteditable=true
Execute menu command
Obj.execcommand
Double Byte character
/[^\x00-\xff]/
Chinese characters
/[\u4e00-\u9fa5]/
Wrap the English string beyond the table width
Word-wrap:break-word; Word-break:break-all;
Transparent background
<iframe src= "1.htm" width=300 height=180 allowtransparency></iframe>
Get style Content
Obj.style.cssText
HTML tags
Document.documentElement.innerHTML
First Style label
Document.stylesheets[0]
The first style in the Styles tab
Document.stylesheets[0].rules[0]
Prevents clicking on the empty link, the page is often reset to the top of the page.
<a href= "javascript:function ()" >word</a>
Previous page Source
Asp:
Request.ServerVariables ("Http_referer")
Javascript:
Document.referrer
Free memory
CollectGarbage ();
No right key
Document.oncontextmenu = function () {return false;}
Prohibit save
<noscript><iframe src= "*.htm" ></iframe></noscript>
Prohibit selection of <body oncontextmenu= "return false" ondragstart= "return false" Onselectstart = ' return false ' onselect= ' Document.selection.empty () "oncopy=" Document.selection.empty () "onbeforecopy=" return false ' return false ' >
Address bar icon
<link rel= "Shortcut Icon" href= "Favicon.ico" >
Favicon.ico name best unchanged 16*16 16 color, put the virtual directory root directory
Favorites Bar Icon
<link rel= "Bookmark" href= "Favicon.ico" >
View Source
<input type=button value= View Web page source code http://www.webjx.com/"target=_blank> http://www.webjx.com/' >
Close IME
<input style= "ime-mode:disabled" >
Auto Select All
<input type=text name=text1 value= "123" >
Enter to move the cursor to the next input box
<input >
Default values for text boxes
<input type=text value= "123" >
Title Line Wrap
Obj.title = "123 SDFs"
The microseconds represented by the acquisition of time
var n1 = new Date ("2004-10-10". Replace (/-/g, "\/")). GetTime ()
Whether the window is closed
Win.closed
CheckBox flat
<input type=checkbox style= "Position:absolute; Clip:rect (5px 15px 15px 5px) "><br>
Get the selection
Document.selection.createRange (). Duplicate (). Text
Auto Completion function
<input Type=text autocomplete=on> to open this feature
<input type=text autocomplete=off> Turn off this feature
Window maximization
<body >
No Close button IE
window.open ("aa.htm", "Meizz", "fullscreen=7");
Unified Coding/Decoding
Alert (decodeuricomponent encodeuricomponent ("http://hello. com?as= hehe"))
encodeURIComponent to ":", "/", ";" and "?" Also encoded
Table row indicates
<tr >

Related Article

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.