Home  >  Article  >  Web Front-end  >  Basic knowledge of Javascript (3) BOM, DOM summary_Basic knowledge

Basic knowledge of Javascript (3) BOM, DOM summary_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 16:34:541339browse

window object:

Open and close windows:

window.open()

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

2. The name of the new window

3. Characteristic string and description of whether to replace the Boolean value of the currently loaded page with the newly loaded page.

window.close()

System dialog:

1.alert("hello world!");

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

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

Time interval

setTimeout("alert('hello world!')",3000) executes hello world only once every 3 seconds

cleanTimeout

setInterval("alert('hello world')".3000) is executed every 3 seconds

CleanInterval

History

window.history.go(-1) returns to the previous page

window.history.back returns to the previous page

window.history.go(1) Go forward one page

window.history.forward forward one page

window.history.length queries the number of pages in history

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 node in DOM:

1.Element node (Element);

2. Attribute node (Attributes);

3. Text node (Text);

4. Comment node (Comment);

Common methods for all types of nodes:

Find:

nodeName: node name

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

nodeType: type of node

firstChild: the first son****

lastChild: the second son****

childNodes: all child nodes***** (two methods)////

previousSibling: points to the previous sibling node (sibling**);

nextSibling: points to the next sibling node (sibling**);

Operation:

attributes: contains an Attr object representing the characteristics of an element, only used for Element nodes

appendChild: Add a new node at the end

removeChild: Delete a node

replaceChild:replace

insertBefore: Add a node before...

Created by:

createElement: Create an element node

createTextNode: Create a text node

Clone: ​​

cloneNode: copy a node true (deep copy) false (shallow 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: Find the Name of the specified element;

Attribute search, change, setting:

getArrtibute: attribute search;

setArrtibute: attribute change For example: setArribute(class, red) first parameter is to change the class, and the second parameter is set to red;

removeAttibute: delete attribute;

Override, add the value of the text:

innerHTML

Statement:
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