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
document.bgColor //Set the page background color
document.fgColor //Set the foreground color (text color)
document.linkColor / /Unclicked link color
document.alinkColor //Color of activated link (focus is on this link)
document.vlinkColor //Clicked link color
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 characters Set Simplified Chinese: gb2312
cookie About cookies, please see the chapter "Using Frameworks and Cookies".
lastModified The last modified date of the current document, which is a Date object.
referrer If the current document was opened by clicking on the connection, referrer returns the original URL.
title refers to the text defined by ... 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.