Solved

The equivalent of window.innerWidth for IE ?

Posted on 2000-02-22
6
319 Views
Last Modified: 2009-07-29
Hi,

I'm using window.innerWidth with Netscape to get the width of the window. But it does not work with IE. The same problem occurs with window.innerHeight.
Any suggestion for IE?
Kind Regards
Stephane
0
Comment
Question by:stephaneeybert
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 8

Expert Comment

by:jbirk
ID: 2547405
You can use:
document.body.clientHeight
document.body.clientWidth
in IE4+

-Josh
0
 

Author Comment

by:stephaneeybert
ID: 2549343
Very good. Thanks mate.
Some well deserved points.
0
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
ID: 2549350
Cool, glad to help
-Josh
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:stephaneeybert
ID: 2549598
By the way I would like to make this function work for IE...


// Display the properties of a layer
function displayProperties(layer) {
  if (nsBrowser()) {
    var str = "";
    for (var p in layer) {
      str += p + " : " + layer[p] + "\n";
      }
    alert(str);
    }
  else if (ieBrowser()) {
    }
  }

Many thanks anyway.
Stephane
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2550529
hmm...  it's hard to tell exactly what you're doing here without seeing more of the code.  I can say that testing with nsBrowser and ieBrowser (obviously previously set variables) isn't necesary, and not always the best depending on the test.

Instead you should test like this (when dealing with layers):
if (document.layers) //netscape
 {

 }
else if (document.all) //ie
 {

 }

I should think that the code would be the same for both however.  Just that setting the variable 'layer' needs to be different.  Oh, and BTW, layer is not a good name since it used by netscape.

The setting of the variable should look something like this:

if (document.layers) //netscape
 {
  myLayer = document.layers.layername.document;
 }
else if (document.all) //ie
 {
  myLayer = document.all.layername;
 }

I'm not sure if this will give you the exact same results since the two browsers work quite a bit differently with dhtml.  Also you have to be sure to create the browser in a cross platform way with div tags...

Anyway, if you have further questions on this, you should open a new question.  I gave you this info free :)

-Josh
0
 

Author Comment

by:stephaneeybert
ID: 2550685
Cheers!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

734 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