在Javascript文件中编写Internet Explorer的条件代码 [英] Writing Conditional Code for Internet Explorer WITHIN a Javascript file
本文介绍了在Javascript文件中编写Internet Explorer的条件代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否可以在Internet Explorer的javascript文件中编写条件javascript 。
I'd like to know if it's possible to write conditional javascript within a javascript file for Internet Explorer.
即。类似这样......
i.e. something like this...
if (is IE7) {
do this } else {
do this instead
});
我知道我可以在头部使用条件注释为IE加载一个完全不同的脚本,但我只是想要更改一小段代码,因此加载完全不同的工作表将是一种昂贵的方式。
I know I can load a completely different script for IE using conditional comments in the head, but I only want to change a small piece of code and so loading a completely different sheet would be an 'expensive' way to do that.
推荐答案
如果您使用的是jquery,则代码执行此操作
If you are using jquery you code do this
if ($.browser.msie && $.browser.version == '6.0') {
//do IE specific code
}
这篇关于在Javascript文件中编写Internet Explorer的条件代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文