Properties, methods, and events for window.document in JavaScript

Source: Internet
Author: User
Tags readable

Property:

1 Attributes Storage node's properties list (read only)
2 childnodes List of sub nodes of storage node (read only)
3 DataType Returns the data type of this node
4 definition of a node given in a DTD or XML schema (read-only)
5 Doctype Specify document type node (read-only)
6 documentelement returns the root element of the document (Readable and writable)
7 FirstChild Returns the first child node of the current node (read-only)
8 Implementation return Xmldomimplementation object
9 LastChild Returns the last child node of the current node (read-only)
Ten nextSibling returns the next sibling node of the current node (read-only)
One nodename return 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 Back to 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)
A URL returns the URL of the most recently loaded XML document (read-only)
XML representation of a node and its descendants (read-only)

Method:

1 AppendChild adds a new child node to the current node, after the last child node
2 CloneNode Returns the copy of the current node
3 CreateAttribute Create a new property
4 Createcdatasection Create a CDATA segment that includes the given data
5 Createcomment Create a comment node
6 Createdocumentfragment Create DocumentFragment Object
7 createelement Create an element node
8 Createentityreference Create EntityReference Object
9 CreateNode Create a node of a given type, name, and namespace
Createporcessinginstruction Create an 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 an XML document at a specified location
Loadxml Import the XML document for the specified string
RemoveChild deletes the specified child node from the list of child nodes
ReplaceChild replaces the specified child node from the list of child nodes
Save the XML file to the specified node
SelectNodes a specified match to a node and returns a list of matching nodes
selectSingleNode a specified match to the node and returns the first matching node
Transformnode converts a node and its descendants using the specified style sheet
transformNodeToObject converts a node and its descendants to objects 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

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.