Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
170
rated 0 times [  175] [ 5]  / answers: 1 / hits: 22960  / 14 Years ago, sun, february 13, 2011, 12:00:00

I have a little problem with JavaScript, to get the screen width we use screen.width which returns the overall screen resolution, is there a command to get the resolution of the visible portion of the browser, like when the browser is not maximized?


More From » screen

 Answers
7
function width(){
return window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth
|| 0;
}

function height(){
return window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight
|| 0;
}


Use them to return the height() or width() of the visible window.



JSFiddle example.


[#93753] Friday, February 11, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
neildrews

Total Points: 166
Total Questions: 103
Total Answers: 85

Location: Moldova
Member since Sat, Aug 6, 2022
2 Years ago
neildrews questions
Fri, Feb 18, 22, 00:00, 2 Years ago
Tue, Oct 12, 21, 00:00, 3 Years ago
Tue, Mar 23, 21, 00:00, 3 Years ago
Sun, Aug 16, 20, 00:00, 4 Years ago
;