Finding innerWidth and innerHeight of window in IE

Posted on 2006-04-15
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:


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

Question by:drakkarnoir
    LVL 11

    Expert Comment

    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.

    Author Comment

    It says object expected when I try to alert(document.body.clientHeight), another useful IE error message.
    LVL 75

    Expert Comment

    by:Michel Plungjan
    Show some code, please
    LVL 14

    Accepted Solution

    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;

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    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…

    728 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

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now