Finding innerWidth and innerHeight of window in IE

The title basically sums it up in a nutshell, I need to find a way to get the width and height of the window minus the toolbars and scrollbars. In firefox I can achieve this with:


IE does not support this, and I've yet to find some other way to do this.

Who is Participating?
Samuel LiewCommented:
You need three sets of code, one for Netscape, one for Explorer 6 if you use a DOCTYPE, and one for Explorer in all other cases:

if (self.innerWidth) {
      frameWidth = self.innerWidth;
      frameHeight = self.innerHeight;
else if (document.documentElement && document.documentElement.clientWidth) {
      frameWidth = document.documentElement.clientWidth;
      frameHeight = document.documentElement.clientHeight;
else if (document.body) {
      frameWidth = document.body.clientWidth;
      frameHeight = document.body.clientHeight;
In IE you can use document.body.clientHeight or document.documentElement.clientHeight for standard mode (non quirks). But these will only work after the body was loaded, i.e. you can access them inside a OnLoad handler.
drakkarnoirAuthor Commented:
It says object expected when I try to alert(document.body.clientHeight), another useful IE error message.
Michel PlungjanIT ExpertCommented:
Show some code, please
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.