Anyone know of a reliable way to get the width of a window, including 
scrollbar offset in FF?

I have "borrowed" the following script that calculates the width of the 
browser window, no matter if the window is maximized or not.  The 
problem I am having with this in FireFox is that when there is a 
scrollbar present or when there is not a scrollbar present, the value is 
the same.  Does anyone know of a way to get the screen width with and 
without the scrollbar?  Oh yea, it has to be cross-browser compatible, 
within reason (FF, NS 6+, IE5.5+).

function alertSize() {
   var myWidth = 0, myHeight = 0;
   if( typeof( window.innerWidth ) == 'number' ) {
     //Non-IE
     myWidth = window.innerWidth;
     myHeight = window.innerHeight;
   } else if( document.documentElement && ( 
document.documentElement.clientWidth || 
document.documentElement.clientHeight ) ) {
     //IE 6+ in 'standards compliant mode'
     myWidth = document.documentElement.clientWidth;
     myHeight = document.documentElement.clientHeight;
   } else if( document.body && ( document.body.clientWidth || 
document.body.clientHeight ) ) {
     //IE 4 compatible
     myWidth = document.body.clientWidth;
     myHeight = document.body.clientHeight;
   }
   window.alert( 'Width = ' + myWidth );
   window.alert( 'Height = ' + myHeight );
}

Thanks,

Ray

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:236556
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to