在Internet Explorer中以Quirks模式加载页面 - doctype已注释掉 [英] Page loading in Quirks mode in Internet Explorer - doctype commented out

查看:133
本文介绍了在Internet Explorer中以Quirks模式加载页面 - doctype已注释掉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是,所有版本的IE都在Quirks模式下在我的网站上呈现单个页面。通过单击链接在新窗口中打开此页面:

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>

窗口使用以下js确定:

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.

我在文本编辑器中检查了我的文件,并在IE和Chrome中查看了源代码(不使用IE中的Inspector工具或Developer Tools),并且在doctype之前没有空格,字符或其他可能会干扰的内容。在IE开发人员工具中查看doctype虽然我看到它被注释掉了。这是我在站点范围内使用的相同doctype结构(来自HTML5 Boilerplate)。没有其他页面有此问题。 doctype声明和元项目如下:

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">

现在,就像我提到的那样,这个页面被加载到一个用一些js打开的新窗口中。如果我右键单击该窗口,并选择刷新,页面权限本身,doctype将不再被注释掉,并且页面在标准模式下正确呈现,而不是Quirks。如果我直接访问此网址,而不是通过新的弹出窗口,它也会正确呈现。

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.

可能导致此问题的原因是什么?这与用于强制打开新窗口的js有关吗?

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!

推荐答案

doctype被注释掉的事实表明该页面正在被处理,好像IE是IE7或更早版本。

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

请注意,< meta http-equiv =X-UA-Compatiblecontent =IE = edge,chrome = 1> 对您的页面没有任何影响,因为您在其前面加上条件注释。那些具有提交IE表现为特定版本的效果。

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.

您可以尝试将X-UA-Compatible,IE = edge设置为真正的HTTP头。这将在条件注释之前处理,因此应强制IE使用其最新模式。

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.

在文件开头检查页面是否有无关字符时,我建议不使用浏览器或文本编辑器,而是使用十六进制编辑器。例如,Hex Editor Neo(免费下载)将允许您直接从URL加载资源,因此您可以看到发送到浏览器的确切字节。

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.

这篇关于在Internet Explorer中以Quirks模式加载页面 - doctype已注释掉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆