javascript - 根据Internet Explorer版本使用JSP加载不同的JS

标签 javascript html jsp

我对 JSP 还算陌生,现在我被一个我们大多数人都不希望遇到的问题所困扰:Internet Explorer 6.0 支持。

我在 Google 上搜索过,但没有找到答案。我的问题是,有没有办法根据浏览器版本在JSP中加载不同的Javascript?

我的算法是: 检查 Internet Explorer 版本。 如果是IE6,则加载ie6.js 否则加载normal.js。

到目前为止,这就是我加载 JS 的方式。

<script type="text/javascript" src="../js/normal.js"></script>

最佳答案

您可以使用conditinal comments为 Internet Explorer 加载不同的 Javascript。

所以,对于你的情况:

<!--[if !IE 6]><!-->
    <script type="text/javascript" src="normal.js" />
<!--<![endif]-->
<!--[if IE 6]>
    <script type="text/javascript" src="ie6.js" />
<![endif]-->

关于javascript - 根据Internet Explorer版本使用JSP加载不同的JS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15105531/

相关文章:

java - 支柱 : call a a method of DispatchAction from another DispatchAction

javascript - 提交按钮 onclick javascript 呈现从 asp.net 2.0 到 4.0 的差异

javascript - 取消设置变量但它不会取消设置

javascript - yarn : add dependency from subdirectory in git repository

java - 将 JSP 文件中的变量分配给 Java String

java - jsp中如何避免检查null

javascript - 菜单管理悬停和点击事件

html - 是否有 IIS 设置提示浏览器进入兼容模式?

javascript - href 中的多个替换字符串共享同一个类

html - 如何突出显示表格中的选定行?