Home > Article > Web Front-end > Basic knowledge of Javascript (3) BOM, DOM summary_Basic knowledge
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