Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with innerHeight innerWidth in FireFox???

Status
Not open for further replies.

theniteowl

Programmer
Joined
May 24, 2005
Messages
1,975
Location
US
Hi All,
I have been attempting to use innerHeight and innerWidth in FireFox to get the dimensions of the display window without the scrollbars added in but for some reason it returns the values WITH the scrollbars????

I wondered why my positioning code was not correctly preventing objects going off the bottom of the screen in FireFox so I started displaying the values only to find out that the innerHeight/Width properties include the scrollbars even though those are supposed to exclude scrollbars in the value.

I use the code below to detect the browser type and set the values into global variables. I confirmed that it properly detects the browser method to use by placing alerts in each position and seeing that only the first method executes.

Code:
function setScrSize() {
  if (self.innerWidth)
  {
    scrWidth = self.innerWidth;
    scrHeight = self.innerHeight;
  }
  else if (document.documentElement && document.documentElement.clientWidth)
  {
    scrWidth = document.documentElement.clientWidth;
    scrHeight = document.documentElement.clientHeight;
  }
  else if (document.body)
  {
    scrWidth = document.body.clientWidth;
    scrHeight = document.body.clientHeight;
  }
}

Any ideas?
From what I read this should never include the scrollbar widths. I even captured the window and dropped it into an image editor to check dimensions and sure enough the reported values go inside the window border but outside of the scrollbars.


Paranoid? ME?? Who wants to know????
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top