→、
Document の題名を取得または設定します。
| Document | Document。 |
|---|
文字列。
指定値: 文書の新しい題名です。代入すると、document.title の返値、文書に表示される題名(ウィンドウのタイトル バーやタブなど)、文書の DOM(HTML 文書の <title> 要素の内容など)にも反映されます。
HTML:
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<script>
alert(document.title); // "Hello World!" と表示
document.title = "Goodbye World!";
alert(document.title); // "Goodbye World!" と表示
</script>
</body>
</html>
Gecko では、このプロパティは HTML、SVG、XUL、その他の文書に適用されます。
HTML 文書では、document.title の初期値は <title> 要素のテキストの内容です。XUL では、<xul:window> またはその他の最上位 XUL 要素の title 属性の値です。
XUL では、文書の読み込みが完了する前に document.title にアクセスした時の動作は未定義です。document.title が空文字を返す場合があり、また document.title を設定しても効果が表れないかもしれません。