DOM:document.title
From MDC
Contents |
[edit] Summary
Gets or sets the title of the document.
[edit] Syntax
title = document.title;
-
titleis a string containing thedocument's title. If the title was overridden by settingdocument.title, returns that value. Otherwise returns the title specified in the markup (see the Notes below).
document.title = newTitle;
-
newTitleis the new title of the document. The assignment affects the return value ofdocument.title, the title displayed for the document (e.g. in the titlebar of the window), but does not affect the DOM of the document (e.g. the content of the<title>element in an HTML document).
[edit] Example
<html> <head> <title>Hello World!</title> </head> <body> <script> alert(document.title); // displays "Hello World!" document.title = "Goodbye World!"; alert(document.title); // displays "Goodbye World!" </script> </body> </html>
[edit] Notes
This property applies to HTML, SVG, XUL, and other documents in Gecko.
For HTML documents the initial value of document.title is the text content of the <title> element. For XUL it's the value of the title attribute of the window or other top-level XUL element.
In XUL, accessing document.title before the document is fully loaded has undefined behavior (document.title may return an empty string and setting document.title may have no effect).