Basic Javascript knowledge (3) BOM and DOM summary_basic knowledge-js tutorial

Source: Internet
Author: User
This is the third article in the Basic Knowledge series. It mainly introduces some of the experiences of BOM and DOM in javascript and is very practical. If you need it, you can refer to the following window object:

Open and Close windows:

Window. open ()

Three parameters: 1. Load the URL of the page in the new window

2. New window name

3. Feature string and Description: whether to replace the Boolean value of the currently loaded page with the newly loaded page.

Window. close ()

System dialog box:

1. alert ("hello world! ");

2. confirm ("Are you sure? "); --- Select

3. prompt ("What is your name? ","");

Interval

SetTimeout ("alert ('Hello world! ') ", 3000) hello world is only executed once every 3 seconds.

CleanTimeout

SetInterval ("alert ('Hello World')". 3000) is executed every 3 seconds.

CleanInterval

History

Window. history. go (-1) back to the previous page

Window. history. back to the previous page

Window. history. go (1) Previous Page

Window. history. forward

Window. history. length

Document Object:

Document. links [0] Access Link

Document. images [0] or document. images ["imgHome"] access images

Document. forms [0] or document. forms ["frmSubscribe"] Access Form

Location object

Href: the complete URL of the currently loaded page

The most important nodes in DOM:

1. Element Node (Elenment );

2. Attribute nodes (Attributes );

3. Text node (Text );

4. Comment the node (Comment );

Common methods for all types of nodes:

Search:

NodeName: node name

NodeValue: the value of the node (mainly for text nodes. If it is an element node, null is returned ;)

NodeType: Node Type

FirstChild: the first son *****

LastChild: the second son *****

ChildNodes: All subnodes ***** (two methods )////

Previussibling: refers to the forward sibling node (same level **);

NextSibling: points to the next sibling node (same level **);

Operation:

Attributes: An Attr object that contains the characteristics of an Element. It is only used for Element nodes.

AppendChild: Add a new node at the end

RemoveChild: deletes a node.

ReplaceChild: replace

InsertBefore: Add a node before...

Create:

CreateElement: Create an element node.

CreateTextNode: Create a text node

Clone:

CloneNode: copy a node true (deep copy) false (light copy)

Access the specified node:

GetElementById: Find the specified Id;

GetElementsByTagName: Find the type of the specified element (in the form of an array );

GetElementsName: query the Name of a specified element;

Attribute search, change, set:

Getarrtivity: Search for properties;

Setarrtivity: Attributes change. For example, setarrivity (class, red). The first parameter is to change the class, and the second parameter is set to red;

Removeattivity: delete an attribute;

Overwrite, add the text value:

InnerHTML

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.