HTML Doctype 设置 / IE Quirks 模式
我正在一个无法访问的开发人员的参数范围内工作,他为我们的产品创建了一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
你无能为力。您的内容管理系统出现故障。您要么需要找到开发人员并让他们修复这个有问题的系统,要么获得一个新的内容管理系统。
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.
强制 IE 使用标准模式
您可以通过添加到 HTML 的 head 部分的开头来 ,也可以通过服务器配置添加等效的 HTTP 标头。然而,这仅适用于 IE8 或更高版本。
You can force IE to use standards mode by adding
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.
页面是如何生成的?
如果您使用 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.
如果您受困于该代码,那么为什么不在构建过程中添加最后一步,即删除这些注释呢?
If you are stuck with that code, then why not add a last step to the build process, one that strips these comments?
是的,这是可能的,但这是一件非常糟糕的事情。UPD。抱歉,不,它不起作用。
但在某些情况下,我们根本无法控制向用户提供的服务。典型情况:贵公司出于某种法律原因有义务使用的支付网关。它们允许您设置页面样式并将您自己的内容放入其中,但它们不允许更改或设置文档类型的方式(并且根本没有设置!)。
因此,受到此链接的启发: http://www.webmasterworld.com/forum91/4856.htm< /a> 和美化的解决方案可能是这样的(将其放在结束正文标记
之前):
但是,您可能还想更改
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>
):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.