Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Previous Table of Contents Next

Chapter 21
The document Object—Colors, Output, and Properties

The document Object

The document object is a property of the window object. Every window object, whether it is a full browser window, a frame, or a JavaScript-generated window, has a document property. The document object encapsulates everything that exists in the content region of the browser’s window or frame. It is the parent object of the Web page’s content, including links, anchors, colors, titles, and so forth. The document object’s properties are spread over the entire HTML document. Some are commonly placed in the Head portion, while others are normally found in its Body portion. The document object does not consist of any event handlers. You might have thought that onLoad, onUnload, and onError belong to this object, but they are actually properties of the window object.

Not all document object’s properties are HTML-driven content. For example, the lastModified property provides the date on which the document was last modified, even though this date is not provided explicitly in the document but rather in the document’s unseen header.

The document object groups many content-related properties, such as text color, background color, and others. It also includes more complex properties which are actually objects, such as forms, links, and image maps.

The title Property

The document’s title is set by default to its complete URL. Most Web page authors replace this title with their own text. It is specified in the <TITLE></TITLE> tag pair in the Head portion. The title, which usually appears in the title bar, also identifies the browser in the operating system’s environment. When the Web page includes frames, the title bar displays the title of the document which contains the frameset. Documents providing the content of the frames may include their own titles, but they don’t affect the title bar.

The document’s title can be scripted via JavaScript as well. Its general reference is document.title. If the document does not make up the main browser window, the reference must be preceded by the specific window to which the document belongs. The title of a frame document is also accessible via JavaScript, using the same procedure.

The document.title property cannot be set by just any JavaScript script, but only during construction of the entire document. You can use the title property in many different ways. Suppose you want your document to have a large header containing the document’s title. Here is such a page’s outline:

<HTML>
<HEAD>
<TITLE>Tomer Shiran's Home Page</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE="JavaScript">
<!--

document.write("<CENTER><H1>" + document.title + "</H1></CENTER>")

// -->
</SCRIPT>
</BODY>
</HTML>

If you do not include the <TITLE></TITLE> tag pair, the title defaults to the complete URL of the document, including any search query, if one is specified. If you place the <TITLE></TITLE> tag pair without text in between, the title still defaults to the URL. If the text between the opening and closing tags does not include any characters but one or more space characters, the document is assumed untitled, and document.title remains an empty string, or a space-filled string in the case of Microsoft Internet Explorer. The property document.title never evaluates to the URL, unless you specifically write the URL between the <TITLE></TITLE> tags.

Because the value of the title bar also identifies the browser application in the operating system environment, neither Netscape nor Microsoft have made it possible to explicitly modify it. Since it would not make any sense to identify an application as scrolling text, for example, the value of the title bar can be assigned only via the document.title property.

Previous Table of Contents Next


With any suggestions or questions please feel free to contact us