Home >Web Front-end >JS Tutorial >JavaScript introductory tutorial (9) Document document object_basic knowledge

JavaScript introductory tutorial (9) Document document object_basic knowledge

WBOY
WBOYOriginal
2016-05-16 18:56:20968browse

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 to HTML's tag<br>document.bgColor //Set the page background color<br>document.fgColor //Set the foreground color (text color) <br>document.linkColor //The color of unclicked links<br>document.alinkColor //Activate the link (The focus is on this link) <br>document.vlinkColor //The color of the clicked link <br>document.URL //Set the URL attribute to open another web page in the same window <br>document.fileCreatedDate // File creation date, read-only attribute <br>document.fileModifiedDate //File modification date, read-only attribute<br>document.fileSize //File size, read-only attribute<br>document.cookie //Set and read cookies <br>document.charset //Set the character set Simplified Chinese: gb2312 <br>Cookie Regarding cookies, please refer to the chapter "Using Frameworks and Cookies". <br>lastModified is the last modified date of the current document, which is a Date object. <br>referrer If the current document was opened by clicking on the link, referrer returns the original URL. <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.
Methods:
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 standard document HTML. The difference between writeln() and write() is that writeln() adds 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 a

 tag, this line break will also be reflected in the document. 
clear() clears the current document.
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 fully read, that is, JavaScript is inserted into the document, then you do not need to use this method.
Now we have enough knowledge to do the following pop-up update notifications that many websites have.

Copy code The code is as follows:



Of course, you can also write an HTML file first and open( ) method directly load this file.
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