0

I have very strange problem specific to IE (confirmed in v8 and v9).
When using jquery to determine div height with:

$('#sys_MainPage').height()

This code returns cca. 260 in Chrome, Firefox and IE (only if I access application using IP address). But, if I access application using server name and IE 8/9, calculated height is 853?

I'm using jquery 1.4.2.

What could be the cause? Is there any proper reason for this weird behaviour?

EDIT: Problem is caused with different compatibility modes:
Site is accessed using IP address: Browser mode: IE8 Document mode: IE8 standards

Using server name: Browser mode: IE8 compat view Document mode: IE7 standards

I solved this with web.config edit but I still don't understand why is browser/document mode different depending on entered url?

Filip
  • 3,257
  • 2
  • 22
  • 38
  • Can you confirm if the site is running in compatability mode for IE8/9 either using IP address or by using server name? – Dave Walker Jan 18 '12 at 17:37
  • @rangitatanz You were right about cause of problem, please look at my edit. Do you know what is the cause? – Filip Jan 19 '12 at 10:26

3 Answers3

1

Your site is switching to compatability mode when it is being viewed from one of these locations.

You can find a way here Force IE8 *not* to use Compatibility View to force it not to switch. However I would still test this in IE7 and make sure that it is not broken for that.

Pretty much what you need to specify is this:

You can override this behavior by using a meta element to specify an X-UA-Compatible http-equiv header, like so:

<meta http-equiv="X-UA-Compatible" content="IE=edge" > or 
<meta http-equiv="X-UA-Compatible" content="IE=8" /> 

As for why it is broken - we would need to look at the site to do that there are hundreds of reasons why.

Community
  • 1
  • 1
Dave Walker
  • 3,498
  • 1
  • 24
  • 25
0

Hard to tell without your CSS/HTML, but try:

.outerHeight()

http://api.jquery.com/outerHeight/

Diodeus - James MacFarlane
  • 112,730
  • 33
  • 157
  • 176
0

It is difficult to say without source code. First use the ie's debbuger and check why the height is so big. Maybe a css bug of ie is causing this.

Second try setting your height on windows load event

  $(window).load(function(){
    alert($('#sys_MainPage').height());
 });
alex
  • 580
  • 1
  • 4
  • 12