Uncaught TypeError: Cannot read property 'msie' of undefined
2015-07-17 16:39
681 查看
Uncaught TypeError: Cannot read property 'msie' of undefined
因为图方便,抄了别人写的一个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浏览器类型。
下面这个是可行的(出处:/article/1781292.html)
判断浏览器类型:
$.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) {}
相关文章推荐
- ZZ:OpenSSL中产生RSA KEY以及读取PEM文件的问题
- Linux内核基于位的自旋锁
- linux面向对象分析(二)
- HDFS-Hadoop分布式文件系统
- 压力测试之apache benchmark
- ClassNotFoundException:org.apache.commons.io.output.DeferredFileOutputStream error while using commo
- 使用 shell 脚本对 Linux 系统和进程资源进行监控
- popoverController
- Linux 基础 —— Linux 进程的管理与监控
- ElasticSearch实战-日志监控平台
- 用sysctl调整linux内核参数
- Linux PS 命令详解
- hadoop笔记(二)
- Linux多网卡配置与绑定
- Nginx禁止通过IP,未绑定域名访问服务器
- OpenStack Weekly Meeting 2015.07.17
- Linux进程的唤醒与睡眠
- Linux学习-12-学习ACL的使用-1
- Linux学习-11-学习Linux 账号管理
- hadoop中的调度器总结