Summary of properties, methods, and events for Window.document

Source: Internet
Author: User

The document property is created as a sub-object of the Window object, which is used to access all the elements in the page, which is easy to organize and easy to learn JS friends
A summary of the properties, methods, and events of window.document in JavaScript, please refer to this article for friends who need it.

Property:

Attributes a list of properties for a storage node (read-only)
ChildNodes List of child nodes of the storage node (read-only)
DataType returns the data type of this node
Definition of a node defined in a DTD or XML schema (read-only)
Doctype the specified 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 returns the parent node (read-only)
Parsed returns whether this node and its child nodes have been parsed (read-only)
Prefix return namespace prefix (read-only)
PRESERVEWHITESPACE specifies whether to preserve whitespace (readable and writable)
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 returns the XML representation of the node and its descendants (read-only)

Method:

AppendChild adds a new child node to the current node, placed after the last child node
CloneNode returns a copy of the current node
CreateAttribute Creating a new property
Createcdatasection Creating a CDATA segment that includes a given data
Createcomment Create a comment node
Createdocumentfragment Creating DocumentFragment objects
CreateElement Creating an Element node
Createentityreference Creating EntityReference Objects
CreateNode Create a node of the given type, name, and namespace
Createporcessinginstruction Creating an action instruction node
createTextNode Creating a text node that includes the given data
getElementsByTagName returns the collection of elements for the specified name
HasChildNodes returns whether the current node has child nodes
InsertBefore inserting a child node before the specified node
Load import XML document at specified location
LoadXML an XML document that imports the specified string
RemoveChild Delete the specified child node from the child nodes list
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 Converting a node and its descendants to an object using the specified style sheet

body-Principal Sub-object

Document.body//Specifies that the start and end of a document body is equivalent to body>/body>
Document.body.bgColor//Sets or gets the background color behind the object
Document.body.link//non-clicked link color
Document.body.alink//Activate link (focus on this link) color
Document.body.vlink//Clicked link color
Document.body.text//Text color
Document.body.innerText//Set text between body>.../body>
Document.body.innerHTML//Set 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 image

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= "func ()"//mouse pointer is triggered when moving to an object
Document.body.onmouseout= "func ()"///mouse pointer is triggered when the object is moved out
———————————————————————
location-Position Sub-object

Document.location.hash//#号后的部分
Document.location.host//domain + port number
Document.location.hostname//Domain name
Document.location.href//Full URL
Document.location.pathname//directory section
Document.location.port//Port number
Document.location.protocol//Network Protocol (http:)
Section after Document.location.search//?

Documeny.location.reload ()//Refresh Web page
Document.location.reload (URL)//Open a new page
Document.location.assign (URL)//Open a new page
Document.location.replace (URL)//Open a new page
———————————————————————
selection-Selection Sub-object
Document.selection
———————————————————————

Images collection (images in a page)

A) by collection reference
Document.images//img tag on the corresponding page
Document.images.length//Number of IMG tags on the corresponding page
Document.images[0]//1th img Tag
Document.images[i]//i-1 img Tag

b) direct reference via Nane property
IMG name= "Oimage"
Document.images.oImage//document.images.name Properties

c) The SRC attribute of the reference picture
Document.images.oImage.src//document.images.name property. src

d) Create an image
var oimage
Oimage = new Image ()
Document.images.oimage.src= "1.jpg"
Also create an IMG/tag on the page that corresponds to the display

———————————————————————-

Forms collection (forms in a page)

A) by collection reference
Document.forms//The form label on the corresponding page
Document.forms.length//Number of/formform labels on the 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/formform j-1 controls

b) direct reference by Tag Name property
/formform name= "Myform" >input name= "Myctrl"/>/form
Document. Myform.myctrl//document. Table sole name. Control Name

c) Access the properties of the form
Document.forms[i].name//Corresponding Form Name> property
Document.forms[i].action//corresponding/formform action> property
document.forms[i].encoding//corresponding/formform enctype> property
Document.forms[i].target//corresponding/formform target> property

Document.forms[i].appendchild (Otag)//Insert a control dynamically
DOCUMENT.ALL.ODIV//reference layer Odiv
document.all.odiv.style.display= "//layer is set to visual
Document.all.odiv.style.display= "None"//layer is set to hidden
Document.getelementid ("Odiv")//referencing objects by Getelementid
Document.getelementid ("Odiv"). style= "
Document.getelementid ("Odiv"). display= "None"
/*document.all represents a collection of all objects in document
Only IE supports this property, 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//With innertext
document.getElementById ("ID"). outerHTML//With innerHTML

The document property is created as a child of the Window object and is the object used to access all the elements in the page. It has some of the following application features:

Attribute/method/Event description
OnClick triggers when a document is clicked
OnDblClick triggered when a document is double-clicked
OnKeyDown triggered when any key is pressed. Priority 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 () captures all document-related events
Close () closes the document flow
GetSelection () returns the currently selected text
Handleevent () invokes the event handler to the specified event
Open () opens the document flow
Releaseevents () releases the captured events
Routeevent () passes the captured event through a normal handler
Write () writes content to the document
Writeln () writes a string with a newline character to the document
Alinkcolor specifying the ALink property of the related label
Anchors contains an array of all anchor tags in the document
BGCOLOR specifies the background color of the associated label.
Cookie designation Cookie
domain specifies the field to serve the document
Embeds contains an array of all embed tags in the document
FGCOLOR Specifies the Text property of the related label
FormName the actual name of each form in the document
Forms contains an array of all form labels in the document
Images contains an array of all the image tags in the document
LASTMODIFIED Specifies the date the document was last changed
Layers an array containing all the labels of a layer in the document
LinkColor Specify the link property of the related label
Links contains an array of all links in the document
Plugins contains an array of all the plug-in in the document
referrer Specifies the referral URL.
Title Caption text
URL specifies the URL of the document
Vlinkcolor specifying the Vlink property of the related label

Summary of properties, methods, and events for window.document

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.