Javascript basic knowledge (iii) BOM DOM summary

  • 2020-03-30 04:03:13
  • OfStack

The window object:

Open and close Windows:

Window. The open ()

Three parameters: 1. The URL of the page that loads the new window

  2. The name of the new window

  3. Property string and Boolean value indicating whether to replace the currently loaded page with the newly loaded page.

Window. The close ()

System dialog box:

1. The alert (" hello world!" );

2. Confirm (" Are you sure the & # 63;" ); - option

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

The time interval

SetTimeout (" alert (' hello world! ')",3000) execute hello world only once every 3 seconds

cleanTimeout

SetInterval ("alert('hello world')".3000) executes 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) forward one page

Window. history. Forward a page

Window.history.length queries to see the number of pages in history

The document object:

Document.links [0] access links

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

Document.forms [0] or document.forms["frmSubscribe"] access forms

Location object

Href: the full URL of the currently loaded page

The most important nodes in the DOM:

1. Element node (Elenment);

2. Attributes;

3. Text node (Text);

4. Comment node (Comment);

Common methods for all types of nodes:

Looking for:

NodeName: nodeName

NodeValue: the value of the node (mainly for text nodes, returns null if it is an element node)

NodeType: the type of node

-leonard: "firstChild.

LastChild: second son * * * * *

ChildNodes: all childNodes *****(two ways)////

PreviousSibling: points to a previousSibling (sibling **);

NextSibling: point to the nextSibling (sibling **);

Operation:

Attributes: an Attr object that contains the attributes of a represented Element and is used only for the Element node

AppendChild: add a new node at the end

RemoveChild: remove a node

ReplaceChild: replace

The insertBefore: in... Add a node earlier

Create:

CreateElement: creates an element node

CreateTextNode: creates a text node

Cloning:

CloneNode: copies a node   True (depth replication)false(shallow replication)

Access the specified node:

GetElementById: finds the specified Id;

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

GetElementsName: finds the Name of the specified element;

Property search, change, set:

GetArrtibute: search for properties;

SetArrtibute: a change of attribute   For example: setArribute(class, red) the first parameter is to change the class, the second parameter is set to red;

RemoveAttibute: remove attributes;

Overwrite, add the value of the text:

innerHTML


Related articles: