A summary of the attributes, methods, and events of window.document in JavaScript, a friend in need can refer to this article.
Properties:
Attributes a list of properties for storage nodes (read-only)
ChildNodes List of child nodes for storage nodes (read-only)
DataType returns the data type of this node
Definition of a node given in a DTD or XML schema (read-only)
Doctype Specify document Type node (read-only)
DocumentElement returns the root element of the document (Readable and writable)
FirstChild returns the first child node of the current node (read-only)
Implementation return Xmldomimplementation Object
LastChild returns the last child node of the current node (read-only)
NextSibling returns the next sibling node of the current node (read-only)
NodeName returns the name of the node (read-only)
NodeType returns the type of the node (read-only)
nodeTypedValue Storage node value (readable and writable)
NodeValue returns the text of the node (readable and writable)
Ownerdocument returns the root document containing this node (read-only)
ParentNode Return parent node (read only)
Parsed returns whether this node and its child nodes have been resolved (read-only)
Prefix return namespace prefix (read only)
PRESERVEWHITESPACE Specifies whether to leave blank (read-write)
PreviousSibling returns the previous sibling node of this node (read-only)
Text returns the textual content of this node and its descendants (readable and writable)
URL returns the URL of the most recently loaded XML document (read-only)
XML representation of the XML return node and its descendants (read-only)
Method:
AppendChild adds a new child node to the current node and places it after the last child node
CloneNode returns the copy of the current node
CreateAttribute Create a new property
Createcdatasection Create a CDATA segment that includes a given data
Createcomment Create a comment node
Createdocumentfragment Create DocumentFragment Object
CreateElement Create an element node
Createentityreference Create EntityReference Object
CreateNode Create a node for a given type, name, and namespace
Createporcessinginstruction Create operation instruction node
createTextNode Create a text node that includes a given data
getElementsByTagName returns the collection of elements of the specified name
HasChildNodes returns whether the current node has child nodes
InsertBefore inserts a child node before the specified node
Load import XML document at specified location
Loadxml an XML document that imports a specified string
RemoveChild deletes the specified child node from the list of child nodes
ReplaceChild to replace the specified child node from the list of child nodes
Save saves the XML file to the specified node
SelectNodes a specified match to the node and returns a list of matching nodes
selectSingleNode a specified match to the node and returns the first matching node
Transformnode the node and its descendants using the specified style sheet
transformNodeToObject converts a node and its descendants to an object using the specified style sheet
body-the principal child object
Document.body//Specifies that the start and end of the document body is equivalent to body>/body>
Document.body.bgColor//Sets or gets the background color behind the object
Document.body.link//not-clicked link color
Document.body.alink//Activate the color of the link (focus on this link)
Document.body.vlink//clicked on link color
Document.body.text//Text color
Document.body.innerText//Set the text between body>.../body>
Document.body.innerHTML//Set of HTML code between body>.../body>
Document.body.topMargin//page top margin
Document.body.leftMargin//Page left margin
Document.body.rightMargin//Page right margin
Document.body.bottomMargin//Page Bottom margin
Document.body.background//Background picture
Document.body.appendChild (Otag)//dynamically generate an HTML object
Common Object Events
Document.body.onclick= "func ()"//mouse pointer Click object is triggered
Document.body.onmouseover= when the "func ()"//mouse pointer moves over an object
Trigger when document.body.onmouseout= "func ()"//mouse pointer moves out of an object
———————————————————————
location-Position child Object
Document.location.hash//#号后的部分
Document.location.host//Domain name + port number
Document.location.hostname//Domain
Document.location.href//Full URL
Document.location.pathname//directory section
Document.location.port//Port number
Document.location.protocol//Network Protocol (http:)
Document.location.search//number of parts after
Documeny.location.reload ()//Refresh Page
Document.location.reload (URL)//Open new page
Document.location.assign (URL)//Open new page
Document.location.replace (URL)//Open new page
———————————————————————
selection-Selection Child Objects
Document.selection
———————————————————————
Images collection (image on page)
A) by reference to the collection
Document.images//the IMG tag on the corresponding page
Document.images.length//The number of IMG tags on the page
Document.images[0]//1th img Tag
Document.images[i]//i-1 img Tags
b) Direct reference through the Nane property
IMG name= "Oimage"
Document.images.oImage//document.images.name Properties
c) referencing the SRC attribute of a picture
Document.images.oImage.src//document.images.name properties. src
d) Create an image
var oimage
Oimage = new Image ()
Document.images.oimage.src= "1.jpg"
Also create an IMG/tag on the page to show
———————————————————————-
Forms Collection (Forms on page)
A) by reference to the collection
Document.forms//corresponding form labels on the page
Number of/formform labels on the document.forms.length//corresponding page
Document.forms[0]//1th/formform label
Document.forms[i]//i-1/formform label
Number of controls in Document.forms[i].length//I-1/formform
DOCUMENT.FORMS[I].ELEMENTS[J]//i-1 j-1 controls in/formform
b) direct reference through the label Name property
/formform name= "Myform" >input name= "Myctrl"/>/form
Document. Myform.myctrl//document. Table Single-name. Control Name
c) Accessing the properties of the form
Document.forms[i].name//Corresponding Form Name> property
Document.forms[i].action//Correspondence/formform action> Properties
Document.forms[i].encoding//Correspondence/formform enctype> Properties
Document.forms[i].target//Correspondence/formform target> Properties
Document.forms[i].appendchild (Otag)//Insert a control dynamically
DOCUMENT.ALL.ODIV//reference layer Odiv
document.all.odiv.style.display= "//Layer set to Visual
Document.all.odiv.style.display= "None"//layer set to hidden
Document.getelementid ("Odiv")//Reference object by Getelementid
Document.getelementid ("Odiv"). style= "
Document.getelementid ("Odiv"). display= "None"
/*document.all represents a collection of all objects in the document
Only IE supports this attribute, so it is also used to determine the type of browser.
4 properties of a Layer object
document.getElementById ("ID"). innertext//Dynamic output text
document.getElementById ("ID"). InnerHTML//Dynamic output HTML
document.getElementById ("ID"). Outertext//InnerText
document.getElementById ("ID"). outerHTML//innerHTML
The document property is created as a child of the Window object and is used to access all the elements in the page. It mainly has the following application characteristics:
Properties/Methods/Events |
Describe |
OnClick |
Triggered when a document is clicked |
OnDblClick |
Triggered when a document is double-clicked |
OnKeyDown |
Triggered when any key is pressed. Precedence over onkeypress Event triggers |
OnKeyPress |
See onkeydown |
OnKeyUp |
Triggered when a pressed key is released |
OnMouseDown |
triggered when the mouse button is pressed |
OnMouseUp |
triggered when the mouse button is released |
Captureevents () |
Capture all document-related events |
Close () |
Close Document Flow |
GetSelection () |
Returns the currently selected text |
Handleevent () |
Calling the event handler to the specified event |
Open () |
Open Document Flow |
Releaseevents () |
To release the captured events |
Routeevent () |
Passing a captured event through a normal handler |
Write () |
Writing to a document |
Writeln () |
Write a string with a newline character in the document |
Alinkcolor |
Specify the ALink property of the related label |
Anchors |
An array that contains all the anchor tags in the document |
BgColor |
Specifies the background color of the related label. |
Cookies |
Specify cookies |
Domain |
Specify the fields that serve the document |
Embeds |
An array containing all the embed labels in the document |
Fgcolor |
Specify the text property of the related label |
FormName |
The actual name of each form in the document |
Forms |
An array that contains all the form labels in the document |
Images |
An array that contains all the image labels in the document |
LastModified |
Specify the date the document was last changed |
Layers |
An array that contains all the labels for the layer in the document |
LinkColor |
Specify link properties for related labels |
Links |
An array that contains all links in the document |
Plugins |
Contains an array of all the plug-in in the document |
Referrer |
Specifies the referral URL. |
Title |
Title text |
Url |
Specify the URL of the document |
Vlinkcolor |
Specify the Vlink property of the related label |