我对 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/