HTML Doctype 设置 / IE Quirks 模式

发布于 2024-08-31 20:47:50 字数 802 浏览 4 评论 0原文

我正在一个无法访问的开发人员的参数范围内工作,他为我们的产品创建了一个 html 生成系统。每当生成新页面时,他都会放置:

<!-- updated page at 05/MAY/2010 02:58.58 -->
<!-- You must use the template manager to modify the formatting of this page. --> 

导致我的代码看起来像:

<!-- updated page at 05/MAY/2010 02:55.30 -->
<!-- You must use the template manager to modify the formatting of this page. -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

我不相信 IE 会读到这个doctype 根本不存在,就像在查看开发人员屏幕时一样,它以 Quirks 模式呈现......还有其他方法可以强制 IE 退出这种可怕的 Quirks 模式吗?我一直在尝试联系开发人员,但他一直无法联系。

提前感谢您可能需要提供的任何帮助。

//编辑:

这是否可以通过javascript来完成,使用加载命令来访问父页面?

I'm working within the parameters of an un-reachable developer, whom has created an html generation system for our products.. Whenever a new page is generated he places:

<!-- updated page at 05/MAY/2010 02:58.58 -->
<!-- You must use the template manager to modify the formatting of this page. --> 

resulting in my code looking like:

<!-- updated page at 05/MAY/2010 02:55.30 -->
<!-- You must use the template manager to modify the formatting of this page. -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

I don't believe IE read's this doctype at all, as when looking at the developer screen, it renders in Quirks mode... is there any other way to force IE out of this horrible Quirks mode? I've been trying to reach the developer but he has been rather un-available..

Thank you in advance for any help you might have to offer.

//EDIT:

Is this possible to do via javascript, to hit the parent page with an on load command?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

荒路情人 2024-09-07 20:47:50

你无能为力。您的内容管理系统出现故障。您要么需要找到开发人员并让他们修复这个有问题的系统,要么获得一个新的内容管理系统。

There is nothing you can do. Your content management system is failing. You either need to find the developer and have them fix this faulty system or get a new content management system.

悸初 2024-09-07 20:47:50

强制 IE 使用标准模式

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

您可以通过添加到 HTML 的 head 部分的开头来 ,也可以通过服务器配置添加等效的 HTTP 标头。然而,这仅适用于 IE8 或更高版本。

You can force IE to use standards mode by adding

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

to the beginning of your head section for the HTML, or you can add the equivalent HTTP header via server configuration. This will only work on IE8 or above, however.

诠释孤独 2024-09-07 20:47:50

页面是如何生成的?

如果您使用 PHP,则可以使用输出缓冲来防止输出模板注释。

How are the pages being generated?

If you are using PHP, you could use output buffering to keep the template comments from being output.

猫腻 2024-09-07 20:47:50

如果您受困于该代码,那么为什么不在构建过程中添加最后一步,即删除这些注释呢?

If you are stuck with that code, then why not add a last step to the build process, one that strips these comments?

琉璃梦幻 2024-09-07 20:47:50

是的,这是可能的,但这是一件非常糟糕的事情。

UPD。抱歉,不,它不起作用。

但在某些情况下,我们根本无法控制向用户提供的服务。典型情况:贵公司出于某种法律原因有义务使用的支付网关。它们允许您设置页面样式并将您自己的内容放入其中,但它们不允许更改或设置文档类型的方式(并且根本没有设置!)。

因此,受到此链接的启发: http://www.webmasterworld.com/forum91/4856.htm< /a> 和美化的解决方案可能是这样的(将其放在结束正文标记 之前):

<!--[if IE]>
<script>
!function() {
var doctype = "<!DOCTYPE html>",
    headHTML = document.head.outerHTML,
    bodyHTML = document.body.outerHTML;

window.doctypeSet = false;

if (window.doctypeSet) return;
setTimeout(function(){
  document.write(
    doctype + 
    "<html>" + 
    headHTML + 
    bodyHTML +
    "</html>"
  );
  window.doctypeSet = true;
}, 0);

}();
</script>
<![endif]-->

但是,您可能还想更改

Yes it is possible, it's a very bad thing to do though.

UPD. Sorry, nope it doesn't work.

But in some cases, we simply don't have control over what is served to the user. Typical situation: a payments gateway that your company is obliged to use for some legal reason. They allow you to style the page and to put your own contents in it, but they don't allow to change or how the doctype is being set (and it's not being set at all!).

So, inspired by this link: http://www.webmasterworld.com/forum91/4856.htm and beautified solution would probably be something like this (put it before your closing body tag </body>):

<!--[if IE]>
<script>
!function() {
var doctype = "<!DOCTYPE html>",
    headHTML = document.head.outerHTML,
    bodyHTML = document.body.outerHTML;

window.doctypeSet = false;

if (window.doctypeSet) return;
setTimeout(function(){
  document.write(
    doctype + 
    "<html>" + 
    headHTML + 
    bodyHTML +
    "</html>"
  );
  window.doctypeSet = true;
}, 0);

}();
</script>
<![endif]-->

However, you might also want to change <!--[if IE]> to something like <!--[if lte IE 9]>, so that IE10 and later doesn't perform this dirty dance. I am not sure if IE10 will also switch to quirksmode if doctype is not present, if it's not switching, then there is no need to do have this code invoked there.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文