?
Solved

Finding innerWidth and innerHeight of window in IE

Posted on 2006-04-15
6
Medium Priority
?
6,768 Views
Last Modified: 2010-05-18
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:

window.innerWidth
window.innerHeight

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

TIA
0
Comment
Question by:drakkarnoir
4 Comments
 
LVL 11

Expert Comment

by:x4u
ID: 16461704
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.
0
 

Author Comment

by:drakkarnoir
ID: 16462913
It says object expected when I try to alert(document.body.clientHeight), another useful IE error message.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 16463885
Show some code, please
0
 
LVL 14

Accepted Solution

by:
sam2912 earned 2000 total points
ID: 16466755
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;
}
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question