【问题标题】:IE Conditional statements in HTML are being removed?HTML 中的 IE 条件语句正在被删除?
【发布时间】:2013-11-18 18:31:13
【问题描述】:

所以我看到了一些很奇怪的东西。我正在运行 Windows 8.1/IE11,不确定这是否重要。

我已插入以下 html cmets。一个是直接从 HTML5 样板中提取的,所以我确信至少是正确的。

当我打开开发工具时,我可以在 IE11 中看到 DOM 中的 cmets,并在 IE10 中使用模拟器。只要我在模拟器中使用文档模式和用户字符串进入 IE9 或更低版本。您在下面看到的所有条件 IE HTML cmets 以及只有条件 IE cmets 出于某种原因无处可见。

有没有人见过这样的事情?有任何线索为什么会发生吗?我已经彻底搜索无济于事。

    <!DOCTYPE html>
<html>
<head>
<title>@ViewBag.PlatformModel.PlatformTitle </title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="~/Scripts/html5shiv.js"></script>
<!--[if lt IE 8]>
        <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->

<!--[if lte IE 7]><link rel="stylesheet" type="text/css" href="~/content/platform/css/ie78.css"/><![endif]-->
<!--[if lt IE 9]>@Styles.Render("~/Content/platform/css/IE78.css")<![endif]-->

<!--// kendo common, kendo theme-->
@Styles.Render("~/Content/kendo-common-styles")
@Styles.Render("~/Content/kendo-theme-styles")

<!--// platform -->
@Styles.Render("~/Content/platform-styles")

<!--// page styles -->
@RenderSection("styles", required: false)

</head>
<body>
<!--[if lt IE 8]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->

【问题讨论】:

  • 我想知道它们是否正在被读取和处理......?
  • “无处可见”,这是怎么回事?您可以从body 部分找到那些conditional comments 创建的内容... IE>9 不允许您在head 部分创建可显示元素,因此它们会自动移动到body。请注意,仿真模式并不完美。

标签: html internet-explorer conditional-statements ie-developer-tools


【解决方案1】:

您可能想要更新 Windows 并安装最新的补丁。 RTM 的 IE11 中的 F12 工具带有一个错误*,其中模拟文档模式不遵守条件 cmets。这个问题已经解决了。

* http://connect.microsoft.com/IE/feedback/details/806767/conditional-comments-do-not-work-when-emulating-document-modes-via-f12-developer-tools

【讨论】:

    猜你喜欢
    • 2014-05-31
    • 2013-04-24
    • 1970-01-01
    • 2012-10-01
    • 2016-08-17
    • 2020-10-22
    • 1970-01-01
    • 2014-07-31
    • 1970-01-01
    相关资源
    最近更新 更多