概要
window オブジェクトに紐付く screen オブジェクトへの参照を返します。
screen オブジェクトは現在のウィンドウがレンダリングされている画面のプロパティを調べるための特別なオブジェクトです。
構文
screenObj = window.screen;
プロパティ
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- デバイス画面の 明るさ (brightness) を調整。0 から 1.0 までの double を設定可能。
イベントハンドラ
screen.onorientationchangeorientationchangeイベントに呼応するハンドラ
メソッド
screen.lockOrientation- 画面の向き(オリエンテーション)をロック (※フルスクリーンもしくはインストール済みアプリケーションでのみ動作)
screen.unlockOrientation- 画面の向き(オリエンテーション)のロックを解除 (※フルスクリーンもしくはインストール済みアプリケーションでのみ動作)
EventTarget からの継承メソッド
-
EventTarget.addEventListener() -
Register an event handler of a specific event type on the
EventTarget. -
EventTarget.removeEventListener() -
Removes an event listener from the
EventTarget. -
EventTarget.dispatchEvent() -
Dispatch an event to this
EventTarget.
例
if (screen.pixelDepth < 8) {
// use low-color version of page
} else {
// use regular, colorful page
}
仕様
DOM Level 0。どの標準にも属しません。