JavaScript can be used to determine the height/width of the screen that is used to be viewing the page. i tried using jQuery height method but it seems some browsers (specifically in IE Compatibility modes) doesn't seem to calculate the height as expected.
Following function can be used to get the actual screen height and width, which is a cross browser compatible solution.
function getWindowHeight(){
return window.innerHeight ||
document.documentElement.clientHeight ||
document.body.clientHeight;
}
function getWindowWidth() {
return window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
}
Cheers
Samitha
Following function can be used to get the actual screen height and width, which is a cross browser compatible solution.
function getWindowHeight(){
return window.innerHeight ||
document.documentElement.clientHeight ||
document.body.clientHeight;
}
function getWindowWidth() {
return window.innerWidth ||
document.documentElement.clientWidth ||
document.body.clientWidth;
}
Cheers
Samitha
No comments:
Post a Comment