Solved

The equivalent of window.innerWidth for IE ?

Posted on 2000-02-22
6
311 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

813 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

12 Experts available now in Live!

Get 1:1 Help Now