Hi all, here i am going to write a simple javascript method to find a window width and height.
JS Method:
function FindWindowSize() {
var myWidth = 0, myHeight = 0; //Initialize the local variable
if (typeof (window.innerWidth) == 'number') {
myWidth = window.innerWidth;
myHeight = window.innerHeight;
} else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
} else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
alert('Width = ' + myWidth + ' Height = ' + myHeight);
}
Calling Place:
window.onload = alertSize;
No comments:
Post a Comment