首页 > 其他 > 详细

Uncaught TypeError: Cannot read property 'msie' of undefined

时间:2015-07-17 18:18:39      阅读:128      评论:0      收藏:0      [点我收藏+]

因为图方便,抄了别人写的一个jquerry插件,运行时“var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? ‘absolute‘ : ‘fixed‘; ”报了Uncaught TypeError: Cannot read property ‘msie‘ of undefined的错误。

网上搜了一下,http://stackoverflow.com/questions/14923301/uncaught-typeerror-cannot-read-property-msie-of-undefined-jquery-tools里面说在jquerry1.9以后,browser属性已经被移除。
上jquerry官网查了一下API,确实已经移除。官网建议使用Modernizr库。
不希望再引入其它库,再上网找其它的解决方案,关键字:jquery1.9浏览器类型。
下面这个是可行的(出处:http://blog.csdn.net/lyc_2011_acm/article/details/8749177

 

判断浏览器类型:
$.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) {}

Uncaught TypeError: Cannot read property 'msie' of undefined

原文:http://www.cnblogs.com/aure/p/4655001.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!