Home > Web Front-end > JS Tutorial > Summary of tips for using Javascript

Summary of tips for using Javascript

巴扎黑
Release: 2017-05-21 18:49:47
Original
1036 people have browsed it

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 active element
document.activeElement
Binding event
document.captureEvents(Event.KEYDOWN);
Access form element
document. all("txt").focus();
document.all("txt").select();
Form command
document.execCommand
Form COOKIE
document. cookie
Menu event
document.oncontextmenu
Create element
document.createElement("SPAN");
Get elements based on the mouse:
document.elementFromPoint(event.x,event. y).tagName=="TD
document.elementFromPoint(event.x,event.y).appendChild(ms)
Form pictures
document.images[index]
Form event binding Define
document.onmousedown=scrollwindow;
Element
document.Form.elements[index]
Object binding event
document.all.xxx.detachEvent('onclick',a) ;
Number of plug-ins
navigator.plugins
Get variable type
typeof($js_libpath) == "undefined"
Drop-down box
Drop-down box.options[index]
Drop-down box Box.options.length
Find object
document.getElementsByName("r1");
document.getElementById(id);
Timing
timer=setInterval('scrollwindow()',delay );
clearInterval(timer);
UNCODE encoding
escape(),unescape
Parent object
obj.parentElement(dhtml)
obj.parentNode(dom)
Exchange Rows of the table
TableID.moveRow(2,1)
Replace CSS
document.all.csss.href = "a.css";
Display side by side
display:inline
Hide focus
hidefocus=true
Wrap according to width
style="word-break:break-all"
Auto refresh

Simple email

Quick transfer To position
obj.scrollIntoView(true)
Anchor

anchors
Web page passing parameters
location.search();
Editable
obj.contenteditable=true
Execute menu command
obj.execCommand
Double-byte characters
/[^ \x00-\xff]/
Chinese characters
/[\u4e00-\u9fa5]/
Let the English string automatically wrap when it exceeds the width of the table
word-wrap: break-word; word-break: break-all;
Transparent background

Get style content
obj.style.cssText
HTML tag
document.documentElement.innerHTML
The first style tag
document.styleSheets[0]
The first style in the style tag
document.styleSheets[0]. rules[0]
Prevent the page from being reset to the top of the page when clicking on an empty link.
word
Previous web page source
asp:
request.servervariables("HTTP_REFERER")
javascript:
document.referrer
Release memory
CollectGarbage();
Disable right-click
document.oncontextmenu = function() { return false;}
Disable saving

Disable selection
Address bar icon

favicon.ico The name is preferably the same 16*16 colors and placed in the root directory of the virtual directory
Favorite Bar Icon

View source code

Turn off the input method

Automatically select all
< ;input type=text name=text1 value="123" onfocus="this.select()">
ENTER key can move the cursor to the next input box

Default value of text box

titleNewline
obj.title = "123 sdfs "
Get the microsecond represented by the time
var n1 = new Date("2004-10-10".replace(/-/g, "\/")).getTime()
Window Whether to close
win.closed
checkbox flat


Get selected Content
document.selection.createRange().duplicate().text
Autocomplete function
Turn on this function
Turn off this function
Maximize window

No close button IE
window.open("aa.htm", "meizz", "fullscreen=7");
Uniform encoding/decoding
alert(decodeURIComponent(encodeURIComponent ("http://你好.com?as= hehe")))
encodeURIComponent also encodes ":", "/", ";" and "?"
Table row instructions
< ;tr onmouseover="this.bgColor='#f0f0f0'" onmouseout="this.bgColor='#ffffff'">

The above is the detailed content of Summary of tips for using Javascript. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template