当前位置: 移动技术网 > IT编程>开发语言>JavaScript > jquery1.9 下检测浏览器类型和版本的方法

jquery1.9 下检测浏览器类型和版本的方法

2019年03月20日  | 移动技术网IT编程  | 我要评论

jquery1.9版本中$.browser已被剔除:

判断类型:

. 代码如下:


$.browser.mozilla = /firefox/.test(navigator.useragent.tolowercase());
$.browser.webkit = /webkit/.test(navigator.useragent.tolowercase());
$.browser.opera = /opera/.test(navigator.useragent.tolowercase());
$.browser.msie = /msie/.test(navigator.useragent.tolowercase());


等号后面的表达式返回的就是 true/false, 可以直接用来替换原来的 $.browser.msie 等。

检查是否为 ie6:

. 代码如下:


// old
if ($.browser.msie && 7 > $.browser.version) {}
// new
if ('undefined' == typeof(document.body.style.maxheight)) {}


检查是否为 ie 6-8:

. 代码如下:


if (!$.support.leadingwhitespace) {}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网