Solved

The equivalent of window.innerWidth for IE ?

Posted on 2000-02-22
6
306 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
Comment Utility
You can use:
document.body.clientHeight
document.body.clientWidth
in IE4+

-Josh
0
 

Author Comment

by:stephaneeybert
Comment Utility
Very good. Thanks mate.
Some well deserved points.
0
 
LVL 8

Accepted Solution

by:
jbirk earned 50 total points
Comment Utility
Cool, glad to help
-Josh
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:stephaneeybert
Comment Utility
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
Comment Utility
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
Comment Utility
Cheers!
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Avoid defining the variables in the global scope; trying to define them in a local function scope. Because:   • Look-up is performed every time a variable is accessed.   • Variables are resolved backwards from most specific to least specific scope…
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
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

9 Experts available now in Live!

Get 1:1 Help Now