Returns the width of the screen.
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
}
Note that not all of the width given by this property may be available to the window itself. When other widgets occupy space that cannot be used by the
window
object, there is a difference in
window.screen.width
and
window.screen.availWidth
。另请参阅
screen.height
.
Internet Explorer will take into account the zoom setting when reporting the screen width. It will only return the real width of the screen if the zoom is set to 100%.
| 规范 | 状态 | 注释 |
|---|---|---|
|
CSSOM (CSS 对象模型) 视图模块
The definition of 'Screen.width' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
width
|
Chrome 40 | Edge 12 | Firefox Yes | IE ? | Opera Yes | Safari 6 | WebView Android 40 | Chrome Android 40 | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 4.0 |
完整支持
兼容性未知
Screen
AnimationEvent
CSS
CSSConditionRule
CSSGroupingRule
CSSKeyframeRule
CSSKeyframesRule
CSSMediaRule
CSSNamespaceRule
CSSPageRule
CSSRule
CSSRuleList
CSSStyleDeclaration
CSSStyleRule
CSSStyleSheet
CSSSupportsRule
CaretPosition
LinkStyle
MediaQueryList
MediaQueryListListener
StyleSheet
StyleSheetList
TransitionEvent