简体   繁体   中英

IE11 issue with displaying html page

I am upgrading Internet Explorer version from IE8 to IE 11. But while testing our code on IE11 there is one issue we are facing.

One of HTTP request basically returns the HTML page from server to client. This request is working fine in IE8 and displaying web page correctly but when we launch that request from IE11 its displaying HTML source code instaed of web page in browser.

I tried to save those source code(which displayed in browser) manually with .html extension and launched locally. Its displaying correctly when launched locally. This means HTML page which is returning from server is correct and there is issue with rendering?

Here is the HTTP header request and response which are different in IE8 and IE11, Grabbed through Fiddler-->

IE 8:

Request Header:

Accept: application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, /

User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.3; .NET4.0C; .NET4.0E)

Response Header:

Content-Type: text/plain; charset=ISO-8859-1

IE 11:

Request Header:

Accept: text/html, application/xhtml+xml, /

User-Agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko

Response Header: Content-Type: text/plain; charset=ISO-8859-1

I am new to all this and not getting what steps to take next. Is this happening due to browser is not able to receive page in correct format? Changing server side code is little bit difficult as server creates pages dynamically. Is there any simple solution for this?

Thanks in advance.

Your Response header's Content-Type is showing "text/plain" which explains why the source is displaying instead of the source getting rendered.

I believe there's no other way but change your server-side code and set the Content-Type to "text/html" of the response when sending the dynamically generated page

With Content-Type: text/plain you're essentially telling the browser yourself "please treat and show this as plain text" - it's just following orders.

The obvious fix is to force the content type to text/html , this should be a minor change in the serverside code. If the webserver is Apache, you could enforce this by using mod_headers and a .htaccess file or some vhost configuration. If the webserver is not Apache, you could use another small Apache server with mod_proxy to add these headers.

I'm highly surprised this went 'right' in IE8, probably you're also triggering quirks (compatibility) mode there. If fixing the content-type directly is not feasible you could try forcing IE11 to run in IE8 mode by adding the following line to the <head> section of the output:

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

This is however an ugly workaround, and it will stay broken in Firefox, Chrome, Safari and other standards-conforming browsers, just like IE11 they will just follow your orders and show the content as plain text. In the end they're just doing as you tell them.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM