I use the following code to get the window width and height
function pageWidth() {
return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
return window.innerHeight != null ? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
I call this javascript during the page load. If I keep my URL as home page and try to open the explorer, I see most of the times, these function give me values equal to 0.
Any idea how to fix it? My problem is, these functions work always but if I call these functions as part of IE home page, they return 0 ( 1 in 4 case).
is there any better way of getting width of a window?
If can help i use this function that is more crossbrowser and you can call it in the event load as michael suggested