Solved

The equivalent of window.innerWidth for IE ?

Posted on 2000-02-22
6
314 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
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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'…
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…

827 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