简体   繁体   中英

Page loading in Quirks mode in Internet Explorer - doctype commented out

I'm having an issue where all versions of IE are rendering a single page on my site in Quirks mode. This page is opened in a new window by clicking a link:

<a href="javascript:void(0);" onclick="popUp();" target="popupWindow">Launch Processor</a>

And the window is determined using the following js:

function popUp(contactId) {
"use strict";
var url, width, height, leftPos, topPos, targetWin;
url = '/company/process';
if (contactId !== undefined && contactId !== null && contactId > 0) {
    url += '?contact_id=' + contactId;
}
width = 900;
height = 800;
leftPos = (screen.width / 2) - (width / 2);
topPos = (screen.height / 2) - (height / 2);
targetWin = window.open(url, 'popupWindow', 'toolbar=no, location=0, directories=no,     status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=' + width + ',     height=' + height + ', top=' + topPos + ', left=' + leftPos).focus();
}

Now, after a ton of research I have tried everything and read various other questions asked here documenting the same issue, like this one and this one .

I've checked my file in my text editor, and viewing the source in IE and Chrome (not using the Inspector tools or Developer Tools in IE) and there are no spaces, characters or other things that may interfere before the doctype. Viewing the doctype in IE developer tools though I see it is commented out. This is the same doctype structure (from HTML5 Boilerplate) I use site-wide. No other pages have this issue. The doctype declaration and meta items are below:

<!doctype html>
<!--[if lt IE 7]><html class="no-js lt-ie9 lt-ie8 lt-ie7 page-company" lang="en"> <![endif]-->
<!--[if IE 7]><html class="no-js lt-ie9 lt-ie8 page-company" lang="en"> <![endif]-->
<!--[if IE 8]><html class="no-js lt-ie9 page-company" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js page-company" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

Now, like I mentioned this page is loaded in a new window that is opened using some js. If I right-click the window, and select refresh, the page rights itself, doctype is no longer commented out and the page is rendered correctly in Standards mode, not Quirks. If I access this url directly, and not through the new popup window, it also renders correctly.

What could cause this? Is this something to do with the js used to force the new window to open?

Thanks in advance for any and all help, I'd really appreciate it!

The fact that the doctype is commented out indicates that the page is being processed as if IE was IE7 or earlier.

Note that having <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> will have no effect for your page because you precede it with conditional comments. Those have the effect of committing IE to behave as a particular version.

You could try setting X-UA-Compatible, IE=edge as a real HTTP header instead. This would be processed before the conditional comments and so should force IE to use its latest mode.

When checking the page for extraneous characters at the start of a file, I recommend not using a browser nor a text editor, but using a hex editor. Hex Editor Neo, for example (a free download) will allow you to load a resource directly from a url, so you can see the exact bytes that are sent to the browser.

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