如何为不同版本的IE加载不同的脚本?

发布于 2024-12-21 09:40:11 字数 1684 浏览 7 评论 0原文

我使用这些脚本来修复 IE 中的错误(黑客)。

每个版本都有一个。

我知道所有东西都有 IE9.js IE8 和 7,但想加载 仅该版本浏览器所需的脚本;

今天我的代码如下:

<!--[if lt IE 7]>
    <script src="@Url.Content("~/Scripts/IE7.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

<!--[if lt IE 8]>
    <script src="@Url.Content("~/Scripts/IE8.js")">IE7_PNG_SUFFIX=".png";</script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

<!--[if lt IE 9]>
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

我不想使用像

我不知道是否还有else,我在网上搜索了一下,没有看到有人对此发表评论。但这将是理想的解决方案。

类似这样的事情:

<!--[if lt IE 7]>
    <script src="@Url.Content("~/Scripts/IE7.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![elseif lt IE 8]-->
    <script src="@Url.Content("~/Scripts/IE8.js")">IE7_PNG_SUFFIX=".png";</script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![elseif lt IE 9]-->
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

我很感谢您的帮助。

I use these scripts to repair the errors in IE (Hacks).

There is one for each version.

I know that everything has IE9.js IE8 and 7 but would like to load
only the necessary script to that version of the browser;

Today my code is as follows:

<!--[if lt IE 7]>
    <script src="@Url.Content("~/Scripts/IE7.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

<!--[if lt IE 8]>
    <script src="@Url.Content("~/Scripts/IE8.js")">IE7_PNG_SUFFIX=".png";</script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

<!--[if lt IE 9]>
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

I would not like to use something like <!--[if eq IE 8]> because I do not know how it would behave in such versions as IE8.5.

I do not know if there is else, I searched the internet and did not see anyone commenting on this. But it would be the ideal solution.

Something like this:

<!--[if lt IE 7]>
    <script src="@Url.Content("~/Scripts/IE7.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![elseif lt IE 8]-->
    <script src="@Url.Content("~/Scripts/IE8.js")">IE7_PNG_SUFFIX=".png";</script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![elseif lt IE 9]-->
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

I appreciate the help.

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

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

发布评论

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

评论(1

寒江雪… 2024-12-28 09:40:11

如果您使用 IE9.js,则不需要包含 IE7/IE8.js

<!--[if lt IE 9]>
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

问题已解决。

You do not need to include IE7/IE8.js if you are using IE9.js

<!--[if lt IE 9]>
    <script src="@Url.Content("~/Scripts/IE9.js")"></script>
    <script src="@Url.Content("~/Scripts/ie7-squish.js")"></script>
<![endif]-->

Problem solved.

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