This article describes how to use the document object in JavaScript. the summary is very detailed. if you need it, refer to the object attributes.
The code is as follows:
Document. title // Set the document title is equivalentTag
Document. bgColor // set the background color of the page
Document. fgColor // Set the foreground color (text color)
Document. linkColor // the link color that has not been clicked
Document. alinkColor // the color of the activation link (focus on this link)
Document. vlinkColor // the color of the clicked link
Document. URL // Set the URL attribute to open another webpage in the same window
Document. fileCreatedDate // file creation date, read-only attribute
Document. fileModifiedDate // file modification date, read-only attribute
Document. fileSize // file size, read-only attribute
Document. cookie // Set and read cookies
Document. charset // set the character set to simplified Chinese: gb2312
========================================================== ====================================
Body-subject sub-object
The code is as follows:
Document. body // specify the beginning and end of the document body, which is equivalent
Document. body. bgColor // Set or obtain the background color behind the object
Document. body. link // the color of the link that has not been clicked
Document. body. alink // the color of the activation link (focus on this link)
Document. body. vlink // the color of the clicked link
Document. body. text // text color
Document. body. innerText // Set...Text
Document. body. innerHTML // Set...Between HTML code
Document. body. topMargin // top margin of the page
Document. body. leftMargin // left margin of the page
Document. body. rightMargin // right margin of the page
Document. body. bottomMargin // bottom margin of the page
Document. body. background // background image
Document. body. appendChild (oTag) // dynamically generate an HTML object
Common Object events
The code is as follows:
Document. body. onclick = "func ()" // the mouse pointer clicks the object to be triggered
Document. body. onmouseover = "func ()" // triggered when the mouse pointer is moved to an object
Document. body. onmouseout = "func ()" // triggered when the mouse pointer is removed from an object
========================================================== ====================================
Location-location sub-object
The code is as follows:
Part after document. location. hash // #
Document. location. host // domain name + port number
Document. location. hostname // domain name
Document. location. href // complete URL
Document. location. pathname // Directory
Document. location. port // port number
Document. location. protocol // Network protocol (http :)
Document. location. search //? Part after
Common Object events
The code is as follows:
Using eny. location. reload () // refresh the webpage
Document. location. reload (URL) // open a new webpage
Document. location. assign (URL) // open a new webpage
Document. location. replace (URL) // open a new webpage
========================================================== ====================================
Images set (images in the page)
A) reference through a set
The code is as follows:
Document. images // tag on the corresponding page
Document. images. length // number of tags on the page
Document. images [0] // 1st tags
Document. images // The I-1 label
B) direct reference through the name attribute
The code is as follows:
Document. images. oImage // document. images. name attribute
C) reference the image's src attribute
The code is as follows:
Document. images. oImage. src // document. images. name attribute. src
D) create an image
The code is as follows:
Var oImage
OImage = new Image ()
Document. images. oImage. src = "1.jpg"
At the same time, you can create a tag on the page to display it.
Sample Code (dynamic image creation ):
The code is as follows: