I am trying to get width and height of device screen size not browser size not resolution and it should be same for both mode landscape and portrait mode. it there any possible way to get it in javascript.
Asked
Active
Viewed 122 times
0
-
what about `screen.width` and `screen.height`? – Suman Bogati Mar 22 '14 at 07:12
-
scree.width and screen.height is not working. this functions are giving browser's width and height. i want screens height and width. as i am executing it on a computer desktop size should come. if on lp then lp screen size should come. hope you are getting it. – Rohitmittal Mar 22 '14 at 07:16
-
Possible duplicate: http://stackoverflow.com/questions/3437786/how-to-get-web-page-size-browser-window-size-screen-size-in-a-cross-browser-wa – Mar 22 '14 at 07:28
1 Answers
0
A non-jQuery way to get the available screen dimension.
Use window.screen.availWidth/Height
.
alert(window.screen.availWidth);
alert(window.screen.availHeight);
http://www.quirksmode.org/dom/w3c_cssom.html#t10 :
availWidth and availHeight - The available width and height on the screen (excluding OS taskbars & such).
-
Not working. I have already tried this. when i use this code and changing view mode form landscape to portrait it is providing me different values. But the screen for the tablet is same. In landscape: height = 1092 width=800 and in portrait height=395 width=1024. but it should be same. because device screen is not changing. hope you are getting it. – Rohitmittal Mar 22 '14 at 07:41
-
@Rohitmittal I get it. But it gets the width of the OS, however it is displayed. I believe it is impossible to get the height of the screen itself regardless how the OS is displayed. – Mar 22 '14 at 16:10