0

I need to get the window width and height in Internet Explorer

Initially I was using a nice simple statement var height = HtmlPage.Window.Eval("innerHeight").ToString();

However I then found out that this doesnt work in IE 8

There appear to be loads of different ways to get the width and height of a window, I am not sure which is the best, but the one below is mentioned here Get the window height

doc = document; var theHeight = Math.max( doc.body.scrollHeight, doc.documentElement.scrollHeight, doc.body.offsetHeight, doc.documentElement.offsetHeight, doc.body.clientHeight, doc.documentElement.clientHeight );

My question is how can I put this into Window.Eval to get the height?

What does the syntax need to be?

If there is a better, more reliable way of getting window width and height please let me know, but it needs to work for different browsers

Paul

Community
  • 1
  • 1
Paul
  • 2,773
  • 7
  • 41
  • 96

1 Answers1

0

untested. just adapting your code...

HtmlPage.Window.Eval("Math.max( document.body.scrollHeight, document.documentElement.scrollHeight, document.body.offsetHeight, document.documentElement.offsetHeight, document.body.clientHeight, document.documentElement.clientHeight )").ToString();

Robert Levy
  • 28,747
  • 6
  • 62
  • 94