Document Object-Javascript script language description
-----------------------
Note: The element name attribute on the page and the name referenced by JavaScript must be case-sensitive.
Otherwise, an error message "the referenced element is null or not an object \\\\\" is displayed \\\\\"
-----------------------
Object Attributes
document. title // set the document title equivalent to the title tag of HTML
document. bgcolor // set the page background color
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 the cookie
document. charset // set the character set to simplified Chinese: gb2312
---------------------
Common Object methods
document. write () // dynamically write content to the page
document. createelement (TAG) // create an HTML Tag object
document. getelementbyid (ID) // get the object with the specified id value
document. getelementsbyname (name) // get the object with the specified name value
document. body. appendchild (otag)
---------------------
Body-subject sub-Object
Document. Body // specify the beginning and end of the document body, which is equivalent to body>/body>
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 body>... /Body> text
Document. Body. innerhtml // set body>... HTML between/body>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
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 the object
-----------------------
Location-location sub-Object
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
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
-----------------------
Selection-Selection Sub-Object
Document. Selection
-----------------------
Images set (images in the page)
A) reference through a set
Document. Images // the IMG tag on the corresponding page
Document. Images. Length // Number of IMG labels on the page
Document. Images [0] // 1st IMG tags
Document. Images [I] // I-1 IMG tag
B) direct reference through the Nane attribute
IMG name = "oimage"
Document. Images. oimage // document. Images. Name attribute
C) reference the image's src attribute
Document. Images. oimage. SRC // document. Images. Name attribute. SRC
D) create an image
VaR oimage
Oimage = new image ()
Document.images.oimage.src000000001.jpg"
At the same time, you can create an IMG/tag on the page to display it.
------------------------
Forms set (forms in the page)
A) reference through a set
Document. Forms // form tag on the corresponding page
Document. Forms. Length // Number of/formform labels on the page
Document. Forms [0] // 1st/formform labels
Document. Forms [I] // The I-1/formform tag
Document. Forms [I]. Length // number of controls in the I-1/formform
Document. Forms [I]. elements [J] // The I-1 control in the J-1/formform
B) direct reference through the label name attribute
/Formform name = "myform"> input name = "myctrl"/>/Form
Document. myform. myctrl // document. form name. Control name
C) Access Form attributes
Document. Forms [I]. Name // corresponding form name> attribute
Document. Forms [I]. Action // corresponding/formform action> attribute
Document. Forms [I]. Encoding // corresponding/formform enctype> attribute
Document.formspolici2.16.tar get // corresponding/formform target> attribute
Document. Forms [I]. appendchild (otag) // dynamically insert a control
Document. All. odiv // reference layer odiv
Document. All. odiv. style. Display = "" // set the layer to visible.
Document. All. odiv. style. Display = "NONE" // The layers are hidden.
Document. getelementid ("odiv") // reference an object through getelementid
Document. getelementid ("odiv"). Style = ""
Document. getelementid ("odiv"). Display = "NONE"
/* Document. All indicates the set of all objects in the document.
Only ie supports this attribute, so it is also used to determine the browser type */
Four attributes of a layer object
Document. getelementbyid ("ID"). innertext // dynamic output text
Document. getelementbyid ("ID"). innerhtml // dynamically output html
Document. getelementbyid ("ID"). outertext // same as innertext
Document. getelementbyid ("ID"). outerhtml // same as innerhtml