IE 7 and XHTML


Recommended Posts

Hi,

I use Vista Ultimate x64 with all the latest patches.

I have setup IIS 7 on my machine and I can access the local website using http://localhost.

In IIS, I have changed the MIME type for "*.html" documents to be served as "application/xhtml+xml".

I have created a couple of XHTML documents (XHTML 1.0 Strict DTD) and placed them in the web directory. One of them is a well-formed XHTML document validated with W3C Validation service. In the other document, I have omitted the closing angle bracket of the End Tag of the html element (e.g. "</html").

Now this is what happens when I open the pages in IE 7 and Firefox:

In IE, I open testpage1.html by typing "http://localhost/testpage1.html" and it works perfectly. When I open the other document "http://localhost/testpage2.html" it still opens but shows a "</html" string at the end because of the wrong tag syntax (omitted angle bracket).

In Firefox, the http://localhost/testpage1.html works fine and when I access http://localhost/testpage2.html it displays the following error message:

XML Parsing Error: unclosed token

Location: http://localhost/testpage2.html

Line Number 14, Column 1:

</html

^

Now the behavior of Firefox is understood and it is as per the specifications of XHTML 1.0. And it also proves that the documents are indeed served as XHTML. If the documents weren't served as XHTML, Firefox wouldn't have displayed the above error message which was evident from another experiment where I configured the pages to be served as "text/html".

However, I don't understand why IE 7 opens both the XHTML documents because I have read at so many places that IE doesn't support XHTML documents served as "application/xhtml+xml". From what I read, I understand that IE 7 should instead prompt me to download and save the files instead of displaying them.

Here is the markup of testpage1.html:

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

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<title>Test</title>

</head>

<body>

<p>Test XHTML</p>

</body>

</html>

In testpage2.html, I have copied the same markup and only removed the last angle bracket (last line would read "</html") to simulate an error.

Can somebody explain why IE7 which doesn't support "application/xhtml+xml" behaves in the way mentioned above?

Am I missing something? Is the default configuration of the IIS 7 has something to do with this?

Thanks

EDIT:

I will also like to add that I have checked the HTTP Response Headers for both IE and Firefox. In both cases the "content-type" is set to "application/xhtml+xml". I am inclined to believe that this behavior of IE has something to do with file name extension (".html" or ".xhtml").

Edited by freak4ever
Link to comment
Share on other sites

Some Windows configurations will show the page in HTML quirks mode because of a certain Windows Registry change. I can't recall the specifics but if you search your Registry for application/xhtml+xml or something similar you'll probably find it.

Link to comment
Share on other sites

  • 2 weeks later...
In IIS, I have changed the MIME type for "*.html" documents to be served as "application/xhtml+xml".

Don't do that, All it does is break normal HTML files and sends XHTML files (*.xhtml) as HTML.

And yeah, you can force IE to treat XHTML as HTML (even with the proper mimetype), Although it's easier to just send it the old mimetype.

Link to comment
Share on other sites

actually, IE (any version, even 8) doesn't support application/xhtml+xml at all, and all you'll get is a download prompt. so just the fact that it's displaying means that somewhere along the line something's ****ing up such that the page isn't being served as xhtml to IE.

edit: now that i think about it, since you assigned the mime type to .html, it's probably being served properly, but since IE can't handle mime types at all, it's just ignoring your mime type and guessing the page to be HTML from the extension, thus rendering it as HTML. The download prompt probably comes from just about everyone serving XHTML with a scripting extension (.php) so IE doesn't know what to do with it, hence a prompt.

Edited by Primexx
Link to comment
Share on other sites

Could you please follow these instructions and report back to us?

(1) Click "Start"

(2) Click "Run"

(3) Type "regedit" (without quotation marks)

(4) Click "OK"

(5) Expand "HKEY_CLASSES_ROOT"

(6) Expand "MIME"

(7) Expand "Database"

(8) Expand "Content Type"

Do you see a folder in the "Content Type" section titled "application/xhtml+xml"? If you do, this probably explains why you are not presented with a download prompt when accessing a document served with the "application/xhtml+xml" mimetype.

If you do see such a folder, click on it. To the right you will see some text, "CLSID". To the right of that text you'll probably see "REG_SZ" and "{25336920-03F9-11cf-8FD0-00AA00686F13}". If that is true, this explains why Internet Explorer is attempting to render the page instead of asking you if you want to download or not. That long string of numbers and letters basically tells programs to treat documents that are served with the "application/xhtml+xml" mimetype as if they were being sent with the "text/html" mimetype. As such, Internet Explorer interprets XHTML documents served with the "application/xhtml+xml" mimetype as regular HTML documents.

That could pose problems when upgrading Internet Explorer in the future. To ensure trouble-free upgrades, you should delete the "application/xhtml+xml" folder by right-clicking on it and then clicking "Delete." Once you delete the folder, restart Windows and test your document again—Internet Explorer should ask you if you want to download the file.

If you did see such a folder and deleted it, are you being asked to download the file? If you did not see such a folder, please reply and let us know.

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.