JavaScript getting started tutorial (9) Document Object

Source: Internet
Author: User

This document describes the current window or the specified window object. It contains the content of the document from Usage: document (current window) or <window Object>. document (specified window)
Attribute:
Document. title // set the document title is equivalent to the <title> tag of HTML.
Document. bgColor // set the background color of the page
Document. fgColor // set the foreground color (text color)
Document. linkColor // The link color that has not been clicked
Document. alinkColor // the color of the activation Link (focus on this link)
Document. vlinkColor // the color of the clicked Link
Document. URL // set the URL attribute to open another webpage in the same window
Document. fileCreatedDate // file creation date, read-only attribute
Document. fileModifiedDate // file modification date, read-only attribute
Document. fileSize // file size, read-only attribute
Document. cookie // set and read cookies
Document. charset // set the character set to simplified Chinese: gb2312
For more information about Cookies, see "use framework and Cookies.
LastModified the last modification Date of the current document, which is a Date object.
Referrer if the current document is opened by clicking the link, the referrer returns the original URL.
Title refers to the text defined by FgColor indicates the text color of the text attribute marked by <body>.
BgColor indicates the background color indicated by the bgcolor attribute marked by <body>.
LinkColor indicates the connection color of the link Property marked by <body>.
AlinkColor indicates the active connection color of the alink attribute marked by <body>.
VlinkColor refers to the accessed connection color represented by the <body> marked vlink attribute.
Method:
Open () open the document so that JavaScript can write data to the current location of the document (the location where JavaScript is inserted. This method is usually not required and automatically called by JavaScript when necessary.
Write (); writeln () writes data to the document. The written data is treated as standard document HTML. The difference between writeln () and write () Is that writeln () adds a line break after data is written. This line feed is only a line feed in HTML. Whether it can be a line feed displayed depends on the position where JavaScript is inserted. For example, if the <pre> label is inserted, the new line feed is also reflected in the document.
Clear () clears the current document.
Close () closes the document and stops writing data. If the write [ln] () or clear () method is used, you must use the close () method to ensure that the changes can be displayed. If the document has not been fully read, that is, JavaScript is inserted in the document, you do not need to use this method.
Now we have enough knowledge to do the pop-up update notifications for many of the following websites.
Copy codeThe Code is as follows:
<Script language = "JavaScript">
Var whatsNew = open ('', '_ blank', 'top = 50, left = 50, width = 200, height = 300, '+
'Menubar = no, toolbar = no, directories = no, location = no, '+
'Status = no, resizable = no, scrollbars = yes ');
WhatsNew.doc ument. write ('<center> <B> Update notification </B> </center> ');
WhatsNew.doc ument. write ('<p> last update date: 0020.8.01 ');
WhatsNew.doc ument. write ('<p> 0020.8.01: added the "My favorites" section. ');
WhatsNew.doc ument. write ('<p align = "right">' +
'<A href = "javascript: self. close ()"> close the window </a> ');
WhatsNew.doc ument. close ();
</Script>

Of course, you can also write an HTML file and load it directly in the open () method.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.