Document: exitFullscreen() メソッド

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

DocumentexitFullscreen() メソッドは、この文書で現在全画面モードで表示されている要素が全画面モードを抜け、画面を以前の状態に戻すことを要求します。これはふつう、以前の Element.requestFullscreen() の呼び出しの効果を取り消します。

構文

js
exitFullscreen()

引数

なし。

返値

ユーザーエージェントが全画面モードから完全に抜けたら解決される Promise です。全画面モードから抜けようとしてエラーが発生したら、プロミスの catch() ハンドラーが呼び出されます。

この例ではマウスボタンで中をクリックするたびに、現在の文書が全画面表示になったり戻ったりします。

js
document.onclick = (event) => {
  if (document.fullscreenElement) {
    document
      .exitFullscreen()
      .then(() => console.log("Document Exited from Full screen mode"))
      .catch((err) => console.error(err));
  } else {
    document.documentElement.requestFullscreen();
  }
};

メモ: もっと完全な例については、Element.requestFullscreen() の例をご覧ください。

仕様書

Specification
Fullscreen API
# ref-for-dom-document-exitfullscreen①

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
exitFullscreen
Returns a Promise

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
No support
No support
Uses a non-standard name.
Requires a vendor prefix or different name for use.
Has more compatibility info.

関連情報