Object properties
document.title // Set the document title equivalent to the HTML
tag
document.bgColor //Set the page background color
document.fgColor //Set the foreground color (text color)
document.linkColor //Color of unclicked links
document.alinkColor //The color of the active link (the focus is on this link)
document.vlinkColor //Color of clicked links
document.URL //Set the URL attribute to open another web page in the same window
document.fileCreatedDate //File creation date, read-only attribute
document.fileModifiedDate //File modified date, read-only attribute
document.fileSize //File size, read-only attribute
document.cookie //Set and read cookie
document.charset //Set the character set Simplified Chinese: gb2312
================================================== =======================
body-body sub-object
document.body //Specify the start and end of the document body is equivalent to
document.body.bgColor //Set or get the background color behind the object
document.body.link //Color of unclicked links
document.body.alink //The color of the active link (the focus is on this link)
document.body.vlink //Color of clicked links
document.body.text //Text color
document.body.innerText //Set the text between ...
document.body.innerHTML //Set the HTML code between ...
document.body.topMargin //Page top margin
document.body.leftMargin //Left margin of page
document.body.rightMargin //Right margin of page
document.body.bottomMargin //Page bottom margin
document.body.background //Background image
document.body.appendChild(oTag) //Dynamicly generate an HTML object
Common object events
document.body.onclick="func()" //Clicking the object with the mouse pointer is triggered
document.body.onmouseover="func()" //Triggered when the mouse pointer moves to the object
document.body.onmouseout="func()" //Triggered when the mouse pointer moves out of the object
================================================== =======================
location-location sub-object
document.location.hash // The part after #
document.location.host //Domain name Port number
document.location.hostname // Domain name
document.location.href // Full URL
document.location.pathname // Directory part
document.location.port // Port number
document.location.protocol // Network protocol (http:)
document.location.search // The part after ?
Common object events
documenty.location.reload() //Refresh the web page
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 collection (images on the page)
a) Reference via collection
document.images
document.images.length //The number of
tags on the corresponding page
document.images[0] //The first
tag
document.images //The i-1th
tag
b) Directly reference
through the name attribute
document.images.oImage //document.images.name attribute
c) Reference the src attribute of the image
document.images.oImage.src //document.images.name attribute.src
d) Create an image
var oImage
oImage = new Image()
document.images.oImage.src="1.jpg"
At the same time, create an
tag on the page to display it accordingly
Sample code (dynamic creation of images):
================================================== ======================
forms collection (forms in the page)
a) Reference via collection
Copy code The code is as follows:
document.forms // The
-------------------------------
b) Directly reference
through the tag name attribute
document.Myform.myctrl //document.form name.control name
-------------------------------
c) Access form attributes
document.forms.name // Corresponding to
-------------------------------
Sample code (form):
-------------------------------
Sample code (checkbox):
ddd
-------------------------------
Sample code (Select):
Copy code