Dom and Window object of JavaScript knowledge point

Source: Internet
Author: User

In the process of learning JavaScript is just a lot of smattering, encountered themselves do not know the attribute method, to the end do not know what JS code to learn why this write why you know this method or property can be used this way.

Dom and Window objects

DOM Basic Operations :

Get node:

Document: Get node, tag, Name property by Element ID

Node pointer: Gets the first child node of the element, the last one, the child node list, the previous one on the sibling node, the parent node of the node

node Operation:

Create nodes: Create element nodes, attribute nodes, text nodes

Insert node: A child node of a node adds a new child node before a node is inserted into a new child node

Replace node: Replaces one of the child nodes with another

Copy node: Creates a copy of the specified node

Delete node: Deletes the specified node

Property Operation:

Get property: Gets the attribute value of the element node specified property

Set properties: Create or change attributes of an element node

Delete attribute: Delete The specified attribute in the element

Text manipulation:

InsertData (offset,string): Inserts a String from the location specified by offset

AppendData (String): Inserts a string at the end of a text node

Deletedate (offset,count): Remove count characters from offset

ReplaceData (off,count,string): Replaced by string from off by count characters

Splitdata (offset): Divides a text node into two nodes from offset

SUBSTRING (Offset,count): Returns the Count node from offset

--------------------------------------------------------------------------------------------------------------- -------------------------------------

Window object

Navigator Navigator Object:

appCodeName: Returns the browser code name

AppName: Return Browser name

AppVersion: Returns the platform and version information for the browser

Cookieenabled: Returns the Boolean value of whether the browser enables cookies

Platform: Returns the operating system platform running the browser

UserAgent: Returns the value of the User-agent header with the client sending server

Screen Display object:

Availheight: Returns the available height of the display screen

Availwidth: Returns the available width of the display screen

Height: Returns the pixel height of the screen

Width: Returns the pixel width of the screen

ColorDepth: Returns the number of digits of the screen color

History Object

Back (): Return to previous URL

Forward (): Returns the latter URL

Go (): Return to a specific page

Location Object

Property:

Hash: Returns or sets the URL starting from the pound sign (#)

Host: Returns or sets the hostname and port number of the current URL

Hostname: Host name of the current URL

href: full URL

Pathname: The path portion of the current URL

Port: Port number of the current URL

Protocol: Protocol

Search: From the question mark (?) URL to start

Method:

Assign (URL): Loading a new document

Reload (): Reload the current page

Replace (Newurl): Replace the current document with a new document

Document Object

Collection:

Anchors[] Imgaes,links,forms

Stroke object array, picture, connection, form

Property:

Cookies: Set or return all cookies related to the current document

Domain: Returns the name of the current document

Referrer: Returns the document URL loaded into the current document

Title: Returns the current document title

Url:url

Method:

Open (): Opens a new document and erases the old content from the document

Close (): Closes the document input stream

Write (): Append write text to the current document

WRITENLN (): Same as Write (), append line break in <pre>

window Control: ()

Moveby:moveby (x, y) moves the specified window according to the given pixel parameters

The Moveto:moveto (x, y) window moves at the specified coordinates (x, y)

Resizeby:resizeby (horizontal, vertical) The current window changes the specified size

Resizeto:resizeto (horizontal width, vertical width)

Scrollby:scrollby (horizontal displacement, vertical displacement) parameter is rolling negative first

ScrollTo: Window contents Scroll to the specified position

Focus Control:

Focus: Getting the spotlight

Blur: Losing focus

Open the close window:

Open

Open ("URL", "Window name", "Window Style")

Opens a new window and loads the specified URL address page in the window

Window style:

Height: Window height cannot be less than 100

Width: cannot be less than 100

Left: cannot have a negative coordinate

Top: Right cannot be negative

Location:yes/no whether the address is displayed

Menubar:yes/no whether the menu bar is displayed

Resizable:yes/no whether to change the window size

Scrollbars:yes/no whether scroll bars are allowed

Status:yes/no whether the status bar is displayed

Toolbar yes/no whether the toolbar

Close

Close (): Specifies to close the browser window

Timer:

SetTimeout: After the current specified number of milliseconds, the auto-execute can code

Cleartimeout: Cancels the timer set by settimeout ()

SetInterval: A function code that specifies recurrence of recurrence

Clearinterval: Cancels the setinterval () set time interval

dialog box:

Alert: Warning Box

Confirm: Confirm Box OK returns true Cancel return False

Prompt: Input box determines return input string cancel return null value

Properties:

Status bar:

Defaultstatus changing the default display of the browser status bar

Status temporarily changes the display of the browser status bar

Window Position:

Ie:

Screenleft The x-coordinate of the upper-left corner of the declaration window

Screentop the y-coordinate of the upper-left corner of the Declaration window

Document.body.scrollLeft declares the current document to scroll right first

Document.documentElement.scrollLeft number of pixels in the past

Document.body.scrollTop declares the current document to scroll down first

Document.documentElement.scrollTop number of pixels in the past

! Ie:

ScreenX The x-coordinate of the upper-left corner of the declaration window

ScreenY the y-coordinate of the upper-left corner of the Declaration window

Pagexoffset declares the number of pixels that the current document has scrolled to the right

pageYOffset declares the number of pixels that the current document has scrolled down

Ff:

Innerheight Returns the height of the document display area of the window

Innerwidth width

Outerheight returns the outer height of the window

Outerwidth width

Other properties:

Opener: Can implement communication between forms under the same domain name one form to another form of opener

Closed: Current window close returns true

Name: Returns or sets the window name

Self: Returns a reference to the current window

Dom and Window object of JavaScript knowledge point

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.