Screen.width
画面の幅を返します。
構文
lWidth = window.screen.width
例
// Crude way to check that the screen is at least 1024x768
if (window.screen.width >= 1024 && window.screen.height >= 768) {
// Resolution is 1024x768 or above
}
注
このプロパティによって与えられた幅のすべてがウィンドウ自体に利用できるとは限らないことに注意してください。他のウィジェットが window
オブジェクトで使用できない空間を占有している場合は、 window.screen.width
と window.screen.availWidth
に違いがあります。 screen.height
も参照してください。
Internet Explorer は、画面の幅を報告する際に拡大率の設定を考慮します。拡大率が 100% に設定されている場合のみ、実際の画面の幅を返します。
仕様書
ブラウザーの互換性
BCD tables only load in the browser