Screen

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

Screen インターフェイスは画面を表し、通常は、現在のウィンドウが描画されている画面であり、 window.screen を使用して取得されます。

なお、ブラウザーはブラウザーのウィンドウの中心がどの画面にあるかを検出することで、報告する現在の画面がどれかを判断します。

プロパティ

親である EventTarget から継承したプロパティもあります

Screen.availTop 非標準

永続的または半永続的なユーザーインターフェイス機能に割り当てられていない最初のピクセルの y 座標を指定します。

Screen.availLeft 非標準

スクリーンの左端からの、最初の利用可能なピクセルの値を返します。

Screen.availHeight

Windows のタスクバーなど、オペレーティングシステムが表示する永続的または半永続的なユーザーインターフェイス機能を除いた画面の高さをピクセル単位で指定します。

Screen.availWidth

ウィンドウで利用可能な水平方向の空間の合計をピクセルで返します。

Screen.colorDepth

画面の色深度を返します。

Screen.height

画面の高さをピクセルで返します。

Screen.left 非標準

メイン画面の左端から現在の画面の左端までの距離をピクセルで返します。

Screen.orientation

現在の画面の向きを返します。

Screen.pixelDepth

画面のピット深度を取得します。

Screen.top 非標準

現在の画面の上端からの距離をピクセル単位で返します。

Screen.width

画面の幅を返します。

Screen.mozEnabled 非標準 非推奨;

論理値です。 false に設定すると、端末の画面がオフになります。

Screen.mozBrightness 非標準 非推奨;

端末の画面の明るさをコントロールします。0 から 1.0 までの倍精度実数値で指定します。

メソッド

親である EventTarget から継承したメソッドもあります

Screen.lockOrientation 非標準 非推奨;

画面の向きをロックします (全画面かインストールしたアプリでのみ動作します)

Screen.unlockOrientation 非標準 非推奨;

画面の向きのロックを解除します。 (全画面時かインストールしたアプリでのみ動作します)

イベント

orientationchange 非推奨;

画面の向きが変化したときに発生します。

js
if (screen.pixelDepth < 8) {
  // 色数の少ないバージョンのページを使う
} else {
  // 通常の色数のページを使う
}

仕様書

Specification
CSSOM View Module
# the-screen-interface

ブラウザーの互換性

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
Screen
availHeight
availLeft
Non-standard
Relative to the Multi-screen origin
Non-standard
availTop
Non-standard
Relative to the Multi-screen origin
Non-standard
availWidth
change event
Experimental
colorDepth
height
isExtended
Experimental
left
Non-standard
Relative to the Multi-screen origin
Non-standard
lockOrientation
Deprecated
mozBrightness
DeprecatedNon-standard
mozEnabled
DeprecatedNon-standard
orientation
orientationchange event
DeprecatedNon-standard
pixelDepth
top
DeprecatedNon-standard
Relative to the Multi-screen origin
DeprecatedNon-standard
unlockOrientation
Deprecated
width

Legend

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

Full support
Full support
Partial support
Partial support
No support
No support
Experimental. Expect behavior to change in the future.
Non-standard. Check cross-browser support before using.
Deprecated. Not for use in new websites.
See implementation notes.
User must explicitly enable this feature.
Requires a vendor prefix or different name for use.
Has more compatibility info.