The Document object for JavaScript

Source: Internet
Author: User

The names of the elements on the page, the Name property, and the JavaScript reference must be identical, including case

Object Properties

Document.title //Set document title equivalent to the title tag of HTML

Document.bgcolor //Set page background color

Document.fgcolor //Set foreground (text color)

Document.linkcolor //non-clicked link color

Document.alinkcolor //Activate link (focus on this link) color

Document.vlinkcolor //clicked link color

Document. URL //Set URL property to open another page in the same window

Document.filecreateddate //File creation date, read-only property

Document.filemodifieddate //File modification date, read-only property

Document.filesize //File size, read-only property

Document.cookie //Set up and read out cookies

Document.charset //Set character sets Simplified Chinese: gb2312

Common Object Methods

document.write () //write content to page dynamically

Document.open () //Open Web page.

Document.close () //Close Web page

Document.body //Specifies the beginning and end of the document 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.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

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

Imgname= "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 = NewImage ()

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/form labels on the corresponding page

Document.forms[0] //1th/form label

Document.forms[i] //i-1/form label

Number of controls in Document.forms[i].length//I-1/form

DOCUMENT.FORMS[I].ELEMENTS[J] //i-1/form j-1 controls

b) direct reference by Tag Name property

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/form action> property

Document.forms[i].encoding //corresponding/form enctype> property

Document.forms[i].target //corresponding/form 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.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 object for JavaScript

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.