Home > Article > Web Front-end > Summary of Document properties and methods of JS_Basic knowledge
document.title //Set the document title equivalent to the HTML title tag
document.bgColor //Set the page background color
document.fgColor //Set the foreground color (text color)
document.linkColor // Color of links that have not been clicked
document.alinkColor //Color of active links (focus is on this link)
document.vlinkColor //Color of links that have been clicked
document.URL //Set URL attributes Thus opening another webpage in the same window
document.fileCreatedDate //File creation date, read-only attribute
document.fileModifiedDate //File modification date, read-only attribute
document.charset //Set the character set Simplified Chinese: gb2312
document.fileSize //File size, read-only attribute
document.cookie //Set and read cookies
—————————————— ——————————
Common object methods
document.write() //Dynamicly 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-body sub-object
document.body //Specify the start and end of the document body Equivalent to body>/body>
document.body.bgColor //Set or get the background color behind the object
document.body.link //The color of unclicked links
document.body.alink //The color of the active link (the focus is on this link)
document.body.vlink //The color of the clicked link
document.body.text //The text color
document.body.innerText / /Set the text between body>.../body>
document.body.innerHTML //Set the HTML code between body>.../body>
document.body.topMargin //The top margin of the page
document.body.leftMargin //Left margin of page
document.body.rightMargin //Right margin of page
document.body.bottomMargin //Bottom margin of page
document.body.background //Background image
document.body.appendChild(oTag) //Dynamicly generate an HTML object
Common object events
document.body.onclick=”func()” //The object clicked by the mouse pointer is Trigger
document.body.onmouseover=”func()” //Trigger when the mouse pointer moves to the object
document.body.onmouseout=”func()” //Trigger when the mouse pointer moves out of the object
— ————————————————————————
location-location sub-object
document.location.hash // The part after #
document.location.host // Domain name and port number // It seems that the host name localhost is returned, but no port number is returned
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 // ? number The last part
documenty.location.reload() //Refresh the webpage
document.location.reload(URL) //Open a new webpage
document.location.assign(URL) //Open a new one Web page
document.location.replace(URL) //Open a new web page
——————————————————————————
selection-selection Sub-object
document.selection
For example:
This is a paragraph. It is only a < em>paragraph.
Yet another paragraph.
This final < em>paragraph has special emphasis.