aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/document/visibilitychange_event
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/ja/web/api/document/visibilitychange_event
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/ja/web/api/document/visibilitychange_event')
-rw-r--r--files/ja/web/api/document/visibilitychange_event/index.html84
1 files changed, 84 insertions, 0 deletions
diff --git a/files/ja/web/api/document/visibilitychange_event/index.html b/files/ja/web/api/document/visibilitychange_event/index.html
new file mode 100644
index 0000000000..9cbebfdd7f
--- /dev/null
+++ b/files/ja/web/api/document/visibilitychange_event/index.html
@@ -0,0 +1,84 @@
+---
+title: 'Document: visibilitychange イベント'
+slug: Web/API/Document/visibilitychange_event
+tags:
+ - API
+ - Document
+ - Event
+ - Reference
+ - Visibility
+ - Web
+ - visibilitychange
+translation_of: Web/API/Document/visibilitychange_event
+---
+<div>{{APIRef}}</div>
+
+<p><code>visibilitychange</code> イベントは、タブのコンテンツが表示状態または非表示状態になったときに document に発生します。</p>
+
+<table class="properties">
+ <tbody>
+ <tr>
+ <th scope="row">バブリング</th>
+ <td>あり</td>
+ </tr>
+ <tr>
+ <th scope="row">キャンセル可能</th>
+ <td>いいえ</td>
+ </tr>
+ <tr>
+ <th scope="row">インターフェイス</th>
+ <td>{{domxref("Event")}}</td>
+ </tr>
+ <tr>
+ <th scope="row">イベントハンドラープロパティ</th>
+ <td>{{domxref("Document.onvisibilitychange", "onvisibilitychange")}}</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Usage_notes" name="Usage_notes">使用上の注意</h2>
+
+<p>このイベントには、更新された文書の表示・非表示状態が含まれていませんが、この情報は document の {{domxref("Document.visibilityState", "visibilityState")}} プロパティから取得することができます。</p>
+
+<h2 id="Examples" name="Examples">例</h2>
+
+<p>この例は、文書が表示状態になった時に音楽を再生し、文書が非表示になった時に音楽を停止します。</p>
+
+<pre class="brush:js notranslate">document.addEventListener("visibilitychange", function() {
+ if (document.visibilityState === 'visible') {
+ backgroundMusic.play();
+ } else {
+ backgroundMusic.pause();
+ }
+});
+</pre>
+
+<h2 id="Specifications" name="Specifications">仕様書</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">仕様書</th>
+ <th scope="col">状態</th>
+ <th scope="col">備考</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('Page Visibility API','#sec-visibilitychange-event','visibilitychange')}}</td>
+ <td>{{Spec2('Page Visibility API')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>
+
+<p>{{Compat("api.Document.visibilitychange")}}</p>
+
+<h2 id="See_also" name="See_also">関連情報</h2>
+
+<ul>
+ <li><a href="/ja/docs/DOM/Using_the_Page_Visibility_API">Page Visibility API の使用</a></li>
+ <li>{{domxref("Document.visibilityState")}}</li>
+</ul>