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. CopyCode The 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.

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.