本文介绍了检查IE8是否使用纯Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前用这种方式检查:

I used to check it this way:

$.browser.msie && $.browser.version == 8

但似乎 $。浏览器已从jQuery的后续版本中删除,

But it seems that $.browser has been removed from the later versinos of jQuery,

所以,

如何我可以用纯粹的javascript检查吗?

How can I check that with just pure javascript?

我试过:

isIE8: navigator.appVersion.indexOf(MSIE 8)> 0

好像这样做,但它看起来不那么好,实际上看起来有很多瑕疵......

Wich seems to Do it, but it doesn't look that good and actually looks like it have many flaws...

任何更好的形式给出?

推荐答案

这比单行更长你可能想要,但比解析UA字符串更安全,因为它是基于实际行为(IE条件评论):

This is longer than the one-liner you probably want, but safer than parsing the UA string, because it's based on actual behaviour (IE conditional comments): https://gist.github.com/paulirish/357741

这篇关于检查IE8是否使用纯Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-12 01:49