Home  >  Article  >  Web Front-end  >  Document document object in JavaScript_Basic knowledge

Document document object in JavaScript_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 19:06:401119browse

The Document document object is a property of the window and frames objects in JavaScript. It is a document displayed in the window or frame. A document describing the current window or the specified window object. It contains the contents of the document from

to .
Usage: document (current window) or .document (specified window)

Attribute:



document.title //Set the document title equivalent In the tag of HTML <br><br>document.bgColor //Set the page background color <br><br>document.fgColor //Set the foreground color (text color) <br><br>document.linkColor / /Unclicked link color<br><br>document.alinkColor //Color of activated link (focus is on this link)<br><br>document.vlinkColor //Clicked link color<br><br>document.URL //Set the URL attribute to open another web page in the same window <br><br>document.fileCreatedDate //File creation date, read-only attribute<br><br>document.fileModifiedDate //File modified date , read-only attribute <br><br>document.fileSize //File size, read-only attribute <br><br>document.cookie //Set and read cookie <br><br>document.charset //Set characters Set Simplified Chinese: gb2312 <br><br>cookie About cookies, please see the chapter "Using Frameworks and Cookies". <br><br>lastModified The last modified date of the current document, which is a Date object. <br><br>referrer If the current document was opened by clicking on the connection, referrer returns the original URL. <br><br>title refers to the text defined by ...<title> in the tag. This property does not accept assignment in Netscape.

fgColor refers to the text color represented by the text attribute of the tag.

bgColor refers to the background color represented by the bgcolor attribute of the tag.

linkColor refers to the link color represented by the link attribute of the tag.

alinkColor refers to the active connection color represented by the alink attribute of the tag.

vlinkColor refers to the color of the visited connection represented by the vlink attribute of the tag.



Method:



open() opens the document so that JavaScript can write data to the current position of the document (referring to the position where JavaScript is inserted). Usually there is no need to use this method, JavaScript will automatically call it when needed.

write(); writeln() writes data to the document, and the written data will be treated as a standard document HTML. The difference between writeln() and write() is that writeln() will add a newline after writing the data. This line break is just a line break in HTML. Whether it can be a line break in the displayed text depends on where the JavaScript is inserted. If inserted within the
 tag, this line break will also be reflected in the document. <br><br>clear() clears the current document. <br><br>close() closes the document and stops writing data. If you use the write[ln]() or clear() method, you must use the close() method to ensure that the changes are displayed. If the document has not been completely read, that is, JavaScript is inserted into the document, then there is no need to use this method. <br><br><br><br>Now we have enough knowledge to do the following pop-up update notifications that many websites have. <br><br> <br><script> <BR>var whatsNew = open('','_blank','top=50,left=50,width=200,height=300,' + <BR>                'menubar=no,toolbar=no,directories=no,location=no,' + <BR>                'status=no,resizable=no,scrollbars=yes'); <BR>whatsNew.document.write('<center><b>更新通知'); <BR>whatsNew.document.write('<p>最后更新日期:00.08.01'); <BR>whatsNew.document.write('<p>00.08.01:增加了“我的最爱”栏目。'); <BR>whatsNew.document.write('<p align="right">' + <BR>                '<a href="javascript:self.close()">关闭窗口'); <BR>whatsNew.document.close(); <BR></script>Of course, you can also write an HTML file first and load the file directly in the open() method.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn