--- title: Screen.width slug: Web/API/Screen/width translation_of: Web/API/Screen/width ---
Zwraca szerokość ekranu.
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
. See also {{domxref("window.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%.
Specyfikacja | Status | Komentarz |
---|---|---|
{{ SpecName('CSSOM View', '#dom-screen-width', 'Screen.width') }} | {{ Spec2('CSSOM View') }} |
{{CompatibilityTable}}
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | 6 | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |