0

I'm investigating why a windows modal dialog does not get IE 7 compatibility setting from Web.Config file.

We currently have the following code in Web.Config:

<httpProtocol>
  <customHeaders>
    <!-- This forces IE7 compatibility for all pages -->
    <add name="X-UA-Compatible" value="IE=EmulateIE7"/>
  </customHeaders>
</httpProtocol>

This works fine for most pages except for my modal dialog. This modal dialog basically lives within another .aspx file. You can think of this as exampleWebPage.aspx. My modal dialog is found in exampleModalDialog.aspx

This is how the modal dialog is invoked from exampleWebPage.aspx:

var returnvalue = OpenModal("../exampleLocation/exampleModalDialog.aspx",
"dialogWidth:1024px;dialogHeight:740px,center:yes;help:no;status:no;resizable:no;scroll:no;");

After further digging around, I found that OpenModal() is our own function which eventually calls window.showModalDialog() which has issues from what I found on the web.

When I press F12 in IE 11 for exampleWebPage.aspx page, I see that the document mode is IE 7.

However, when I press F12 again after opening the modal dialog in IE11, I get the following: Browser Mode: IE 11 Document Mode: IE 5 quirks

I have read this SO post: Force IE8 Into IE7 Compatiblity Mode

What I have tried so far to fix this is going into exampleModalDialog.aspx and adding the following code after the header tag.

    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

So that it looks like this:

<html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
        <meta name="..." content="..."/>

Unfortunately, this did not work. Any suggestions?

Community
  • 1
  • 1
SpartaSixZero
  • 2,183
  • 5
  • 27
  • 46

1 Answers1

0

The problem is that your HTML in your dialog box is invalid.

Specifically, the most common cause is if you don't have a DOCTYPE declaration at the top of your code; this will always force IE to go into quirks mode, regardless of any X-UA-Compatible settings you may have.

Other errors in the HTML code can also trigger IE to go into quirks mode, but a missing doctype is by far the most common.

Since you seem to be using xhtml, you will need to use one of the xhtml doctypes. You can find a list of valid doctypes here, but I suggest probably this one:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Add that line to the top of your code, above the <html> tag, and it should stop going into quirks mode.

Spudley
  • 166,037
  • 39
  • 233
  • 307