如何使用IE10条件注释优化asp.net网站兼容性?

2026-04-24 16:062阅读0评论SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计653个文字,预计阅读时间需要3分钟。

如何使用IE10条件注释优化asp.net网站兼容性?

在IE10中测试我的ASP.NET MVC(基于Razor的)网站时,需要设置IE特定的CSS。使用IE条件注释时,若将IE10切换到IE8标准渲染模式,以下语法有效:` link href=@Url.Content(~/Content/global/gl) -->`

在IE10中调试我的ASP.NET MVC(基于Razor的)网站时,我还需要设置IE特定的css.使用IE条件注释时,在将IE10切换到IE8标准渲染模式时,以下语法有效:

<!--[if IE]><!--> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <!--<![endif]-->

而这 – 不是:

<!--[if IE]> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <![endif]-->

后面的语法在大多数提供条件注释信息的站点上作为示例提供,包括MSDN上的官方页面.这两者有什么区别?先感谢您.

使用“Downlevel-revealed Conditional Comments”让它运作起来……

句法:

<![if IE]> ...statements... <![endif]>

例:

<![if IE]> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <![endif]>

更多信息:

某些验证服务将下层显示的条件注释语法标记为无效HTML.可以添加其他字符以在要显示的HTML内容之前和之后构造有效的HTML注释.

<!--[if !IE]>--> YOUR HTML <!--<![endif]-->

在上面的示例中,负条件表达式阻止Internet Explorer在下层显示的条件注释块中显示HTML内容.但是,如果条件表达式的计算结果为true,则结束“ – >”第一条评论与Internet Explorer中的HTML内容一起出现.要从Internet Explorer用户隐藏这些字符,请添加“

如何使用IE10条件注释优化asp.net网站兼容性?

<!--[if !IE]><!--> YOUR HTML <!--<![endif]-->

例子:

以下是一些条件注释的例子.

<!--[if IE]><p>You are using Internet Explorer.</p><![endif]--> <![if !IE]><p>You are not using Internet Explorer.</p><![endif]> <!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]--> <!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]--> <!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]--> <!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]--> <!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]--> <!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]--> <!--[if true]>You are using an <em>uplevel</em> browser.<![endif]--> <![if false]>You are using a <em>downlevel</em> browser.<![endif]> <!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->

内容取自Valid HTML for downlevel-revealed conditional comments

本文共计653个文字,预计阅读时间需要3分钟。

如何使用IE10条件注释优化asp.net网站兼容性?

在IE10中测试我的ASP.NET MVC(基于Razor的)网站时,需要设置IE特定的CSS。使用IE条件注释时,若将IE10切换到IE8标准渲染模式,以下语法有效:` link href=@Url.Content(~/Content/global/gl) -->`

在IE10中调试我的ASP.NET MVC(基于Razor的)网站时,我还需要设置IE特定的css.使用IE条件注释时,在将IE10切换到IE8标准渲染模式时,以下语法有效:

<!--[if IE]><!--> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <!--<![endif]-->

而这 – 不是:

<!--[if IE]> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <![endif]-->

后面的语法在大多数提供条件注释信息的站点上作为示例提供,包括MSDN上的官方页面.这两者有什么区别?先感谢您.

使用“Downlevel-revealed Conditional Comments”让它运作起来……

句法:

<![if IE]> ...statements... <![endif]>

例:

<![if IE]> <link href="@Url.Content("~/Content/global/global.ie.css")" rel="stylesheet" type="text/css"> <![endif]>

更多信息:

某些验证服务将下层显示的条件注释语法标记为无效HTML.可以添加其他字符以在要显示的HTML内容之前和之后构造有效的HTML注释.

<!--[if !IE]>--> YOUR HTML <!--<![endif]-->

在上面的示例中,负条件表达式阻止Internet Explorer在下层显示的条件注释块中显示HTML内容.但是,如果条件表达式的计算结果为true,则结束“ – >”第一条评论与Internet Explorer中的HTML内容一起出现.要从Internet Explorer用户隐藏这些字符,请添加“

如何使用IE10条件注释优化asp.net网站兼容性?

<!--[if !IE]><!--> YOUR HTML <!--<![endif]-->

例子:

以下是一些条件注释的例子.

<!--[if IE]><p>You are using Internet Explorer.</p><![endif]--> <![if !IE]><p>You are not using Internet Explorer.</p><![endif]> <!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]--> <!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]--> <!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]--> <!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]--> <!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]--> <!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]--> <!--[if true]>You are using an <em>uplevel</em> browser.<![endif]--> <![if false]>You are using a <em>downlevel</em> browser.<![endif]> <!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->

内容取自Valid HTML for downlevel-revealed conditional comments