我对JSP有点陌生,现在我陷入一个我们大多数人都不希望遇到的问题:Internet Explorer 6.0支持。
我搜寻了Google,但没有找到答案。我的问题是,有没有一种方法可以根据浏览器版本在JSP中加载不同的Javascript?
我的算法是:
检查Internet Explorer版本。
如果是IE6,请加载ie6.js
ELSE加载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]-->