MDN explains how to use the window.screen
object, but also says "DOM Level 0. Not part of specification."
W3Schools says that window.screen.*
properties are supported in all major browsers.
If I understand this correctly... window.screen
is pletely non-standard, but is nonetheless universally supported. Is that right?
If this is the case, are there any cross-browser differences I need to be aware of, or can I just use it? I'm mostly interested in screen.availWidth
, by the way.
MDN explains how to use the window.screen
object, but also says "DOM Level 0. Not part of specification."
W3Schools says that window.screen.*
properties are supported in all major browsers.
If I understand this correctly... window.screen
is pletely non-standard, but is nonetheless universally supported. Is that right?
If this is the case, are there any cross-browser differences I need to be aware of, or can I just use it? I'm mostly interested in screen.availWidth
, by the way.
- if you deviate from standards, your code could break in future browsers. – Billy Moon Commented Sep 7, 2011 at 17:02
- 1 The Screen interface is specified in the CSSOM View standard. – Šime Vidas Commented Sep 7, 2011 at 17:09
-
The DOM is really just about abstract documents, so it has no notion of an actual output device. In practice, every browser will of course have to provide an output device of some sort (though you could image
wget
to include a DOM-bound scripting engine that has no output device). That's whywindow
isn't in the DOM (though it may well be standardised elsewhere, as Sime's link suggests). – Kerrek SB Commented Sep 7, 2011 at 17:14 - @Kerrek The Window interface is specified in the HTML standard. (Btw there are a couple of extensions to the Window interface which are specified in other standards...) – Šime Vidas Commented Sep 7, 2011 at 17:17
-
Sime: Personally I like to think of HTML 5 as a large, loose collection of many different standards -- it's a huge hodgepodge of all sorts of diverse technologies... but good to know that
window
is included :-) – Kerrek SB Commented Sep 7, 2011 at 17:18
2 Answers
Reset to default 12Quirksmode patibility tables to the rescue!
http://www.quirksmode/dom/w3c_cssom.html#screenview
Most, but not all values are supported by the major browsers.
You should be fine with it.
The reason that it is not part of a standard is because DOM Level 0 was introduced before standards were around. DOM Level 0 is also called the Legacy DOM, and it was created at the same time NetScape 2.0 made JavaScript in the browser a reality; in effect, DOM Level 0 was the very first DOM spec.
The Legacy DOM will be around for a long time, if not then it would break backward patibility with a TON of very popular scripts already in existence.
EDIT: In other words, your understanding is pletely correct. It is not "standardized" but it is pletely universal and will remain so for a long time.