Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it safe to use window.screen?

Tags:

javascript

dom

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 completely 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.

like image 415
callum Avatar asked Sep 07 '11 16:09

callum


People also ask

Should you use window screens?

Screens don't only increase your curb appeal; when they are in good working condition and kept nice and clean, they can also help to keep your exterior window panes from getting dirty. Clean window screens won't cause dirt to splatter on your window glass.

Why do people use window screens?

It serves as the primary barrier between the exterior and interior of your home. Window and door screens are mandatory if you like to let fresh air into your home. Screens also protect glass and doors from abuse like a ball flying at a window from your children playing outdoors.

Should I take screens out of windows?

Your window screens are not just a barrier for sunlight but also for heat. Removing the screens will increase your solar heat absorption as well as your home's energy efficiency — giving your heating system a break and saving you money.


2 Answers

Quirksmode compatibility tables to the rescue!

http://www.quirksmode.org/dom/w3c_cssom.html#screenview

Most, but not all values are supported by the major browsers.

like image 108
Martin Tournoij Avatar answered Sep 23 '22 23:09

Martin Tournoij


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 compatibility with a TON of very popular scripts already in existence.

EDIT: In other words, your understanding is completely correct. It is not "standardized" but it is completely universal and will remain so for a long time.

like image 22
Doug Stephen Avatar answered Sep 23 '22 23:09

Doug Stephen