From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- files/ja/web/api/document/title/index.html | 80 ++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 files/ja/web/api/document/title/index.html (limited to 'files/ja/web/api/document/title/index.html') diff --git a/files/ja/web/api/document/title/index.html b/files/ja/web/api/document/title/index.html new file mode 100644 index 0000000000..e4daa979fd --- /dev/null +++ b/files/ja/web/api/document/title/index.html @@ -0,0 +1,80 @@ +--- +title: Document.title +slug: Web/API/Document/title +tags: + - API + - Command API + - Document + - HTML DOM + - NeedsSpecTable + - Property + - Reference +translation_of: Web/API/Document/title +--- +
{{APIRef("DOM")}}
+ +

document.title プロパティは、現在の文書の題名を取得または設定します。

+ +

構文

+ +
var docTitle = document.title;
+
+ +

docTitledocument の題名を含む文字列です。題名が document.title に設定することで上書きされている場合は、その値を含みます。そうでなければ、マークアップの中で指定された題名を含みます (下記の{{Anch("Notes", "メモ")}}を参照)。

+ +
document.title = newTitle;
+
+ +

newTitle は文書の新しい題名です。代入すると、 document.title の返値、文書に表示される題名 (ウィンドウのタイトルバーやタブなど)、文書の DOM (HTML 文書の <title> 要素の内容など) にも反映されます。

+ +

+ +
<!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 では、 {{XULElem("window")}} またはその他の最上位 XUL 要素の {{XULAttr("title")}} 属性の値です。

+ +

XUL では、文書の読み込みが完了する前に document.title にアクセスした時の動作は未定義です。 document.title が空文字を返す場合があり、また document.title を設定しても効果が表れないかもしれません。

+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('HTML WHATWG','#document.title','document.title')}}{{Spec2('HTML WHATWG')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Document.title")}}

-- cgit v1.2.3-54-g00ecf