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