条件注释适用于除 IE 8 及更低版本之外的所有浏览器

发布于 2024-09-25 04:27:03 字数 202 浏览 1 评论 0原文

如何为应该在除 IE 8 及更低版本之外的所有浏览器上运行的脚本编写条件注释?

我看到 'Except IE8' 的条件注释?

但我如何调整它以包括脚本文件不是内联脚本?

how can i write a conditional comment for scripts that should run for all browsers except IE 8 and below?

i saw Conditional comment for 'Except IE8' ?

but how do i adapt it to include scripts files not inline scripts?

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

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

发布评论

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

评论(1

素年丶 2024-10-02 04:27:03

该技巧解释说,对于外部脚本也同样适用 - 在条件注释的内联脚本中设置“此浏览器是旧的”标志,并让外部脚本检查该标志。

如果您打算有条件地包含整个脚本文件,那么最好的选择可能是浏览器嗅探并动态包含适当文件的脚本。否则,您可以使用下层显示的条件注释(谢谢,bobince!)。

The trick explained there would work just as well for external scripts — set a "this browser is old" flag in a conditional-commented inline script, and have your external scripts check for that flag.

If you mean to conditionally include entire script files, your best bet would probably be a script that browser-sniffs and dynamically includes the appropriate files. Otherwise, you could use downlevel-revealed conditional comments (thanks, bobince!).

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