Solved

The equivalent of window.innerWidth for IE ?

Posted on 2000-02-22
6
315 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
  • 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
Industry Leaders: 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Problem evaluating javascript equality expression 8 17
Jquery 7 32
Html using "Or" in condition 3 26
Building JSON/JQuery Results Display 11 25
In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
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 …
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…

749 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