Document attributes and methods of JS

Source: Internet
Author: User

JS Document attributes and Methods document. title // set the document title is equivalent to the title Tag document of HTML. bgColor // set the background color of the page document. fgColor // set the foreground color (text color) document. linkColor // The link color document that has not been clicked. alinkColor // The Color document of the activation Link (focus on this link. vlinkColor // The selected link color document. URL // set the URL attribute to open another webpage document in the same window. fileCreatedDate // file creation date, read-only attribute document. fileModifiedDate // file modification date, read-only attribute document. charset // set the character set to simplified Chinese: gb2312document. fileSize // file size, read-only attribute document. cookie // Set and read the cookie ----------------------- Common Object method document. write () // dynamically write content to the page document. createElement (Tag) // create an html Tag object document. getElementById (ID) // get the object document with the specified ID value. getElementsByName (Name) // get the object document with the specified Name value. body. appendChild (oTag) ----------------------- body-subject sub-object document. body // specify the beginning and end of the document body. It is equivalent to body>/body> document. body. bgColor // set or obtain the background color document after the object. body. link // The link color document that has not been clicked. body. alink // activation Link (Focus on this link) color document. body. vlink // The selected link color document. body. text // text document. body. innerText // set the body>... /Body> text between document. body. innerHTML // set body>... /Body> between HTML code document. body. topMargin // The top margin of the page document. body. leftMargin // the left of the page is from document. body. rightMargin // the right side of the page is from document. body. bottomMargin // The bottom margin of the page document. body. background // background image document. body. appendChild (oTag) // dynamically generates an HTML object Common Object event document. body. onclick = "func ()" // The mouse pointer clicks the object to trigger the document. body. onmouseover = "func ()" // triggers document when the mouse pointer moves to an object. body. onmouseout = "func ()" // triggered when the mouse pointer is removed from the object --------------------- location-location Sub-object document. location. part of the document after hash. location. host // domain name + port number // it seems that the returned host name is localhost, and no document port is returned. location. hostname // domain name document. location. href // complete URLdocument. location. pathname // directory part document. location. port // port number document. location. protocol // network protocol (http: document. location. search //? Part of the signature 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-Select Sub-object document. selection example: <div> select some text here. </Div> <input type = "button" value = "select some text and click here to execute empty" onclick = "javascript: Foo (); "/> </div> <script type =" text/javascript "language =" javascript "> <! -- Function Foo () {document. selection. empty () ;}--> </script> selection's createRange method document. selection. createRange () returns the TextRange object based on the current text selection, or returns the ControlRange object based on the control selection. ExecCommand can be used in HTML editors, such as bold text, italic text, copying, pasting, and hyperlink creation. These seem to be implemented only in IE .. ----------------------- Images set (image in the page) a) References document through the set. images // the img Tag document on the corresponding page. images. length // The number of img labels on the corresponding page document. images [0] // 1st img tags document. images [I] // I-1 img Label B) References img name = "oImage" document directly through the name attribute. images. oImage // document. images. name attribute c) reference the image's src attribute document. images. oImage. src // document. images. name attribute. srcd) create an image var oImageoImage = new image(%document.images.oimage.src%%%1.jpg "and create The img/label corresponds to it to display ------------------------ forms set (Form in the page) a. Reference document through the set. forms // The form tag document on the corresponding page. forms. length // corresponds to the number of/formform labels on the page document. forms [0] // 1st/formform tag document. forms [I] // The I-1/formform tag document. forms [I]. length // The number of controls in the I-1/formform document. forms [I]. elements [j] // The I-1 control B in the J-1/formform) use the label name property to directly reference/formform name = "Myform"> input name = "myctrl"/>/formdocument. myform. myctrl // docu Ment. form name. control name c) Access Form attribute document. forms [I]. name // corresponding form name> attribute document. forms [I]. action // corresponding to/formform action> attribute document. forms [I]. encoding // corresponds to/formform enctype> terradocument.formspoliciunc.tar get // corresponds to/formform target> attribute document. forms [I]. appendChild (oTag) // dynamically insert a control document. all. oDiv // reference layer oDivdocument. all. oDiv. style. display = "" // set the layer to a visual document. all. oDiv. style. display = "none" // set the layer to hide document. getElementId ("oDiv ") // Reference the object document through getElementId. getElementId ("oDiv "). style = "" document. getElementId ("oDiv "). display = "none"/* document. all indicates that the set of all objects in the document only supports this attribute by ie. Therefore, it is also used to determine the browser type */four attributes of the layer object document. getElementById ("ID "). innerText // dynamically output the text document. getElementById ("ID "). innerHTML // dynamically output HTMLdocument. getElementById ("ID "). outerText // same as innerTextdocument. getElementById ("ID "). outerHTML // same as innerHTML/* PCAS (Province City Ar Ea Selector province, city, and region association select JS encapsulation class) Ver 2.01 Data Compression full version * \ production time: Update Time: Data Correction: document size: 18KB demo address: http://www.popub.net/script/PCAS.html: http://www.popub.net/script/PCASClass.js application Description: The page contains <script type = "text/javascript" src = "PCASClass. js "> </script> new PCAS (" Province "," City ") new PCAS (" Province "," City "," Jilin Province ") new PCAS ("Province", "City", "Jilin Province", "Jilin City") linkage between provinces and cities new PCAS ("Province", "City", "Are A ") new PCAS (" Province "," City "," Area "," Jilin Province ") new PCAS (" Province "," City "," Area ", "Jilin Province", "Songjiang District") new PCAS ("Province", "City", "Area", "Jilin Province", "Songjiang District ") the value obtained by the province, city, and Region object is the actual value. Note: the value of the province, city, and Region prompt information option is "" (empty string)

Related Article

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.