-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget browser screen size - ViewPort (notes).txt
46 lines (22 loc) · 2.06 KB
/
get browser screen size - ViewPort (notes).txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
https://forum.jquery.com/topic/how-to-get-browser-screen-width-height-size
____________________________________________________________________
http://blog.jquery.com/2012/08/30/jquery-1-8-1-released/
Don’t use Quirks mode! jQuery has never supported Quirks mode and we do not perform any testing in Quirks.
This can affect values like $("window").height(), and the jQuery 1.8 Quirks mode results did change in order to support some modern browser features.
The majority of problem cases we’ve seen are from developers that wanted to be in Standards mode but had an invalid doctype or extraneous markup
before their <html> tag. When in doubt, use the simple and short <!doctype html>.
_____________________________________________________________________
It seems that there is no way to get browser viewport size in "quirks mode"!
so, the best way to go seems to be by using <!doctype html> declaration and use
jquery $(window).width()/$(window).height() or javascript document.documentElement.clientWidth/document.documentElement.clientHeight
_____________________________________________________________________
Tested all the doctypes declarations below and through all of them it's possible to get the correct browser viewport size:
Common DOCTYPE Declarations (html 5 "<!DOCTYPE html>" seems to be the recommended one):
<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">