浏览器Console提示cannot read property 'msie' of undefined的解决方法 (转载)

  • 2021-03-23 07:08
  • by 刘管家
  • 10086
  • 0
  • 0
  • jquery,msie

  

练习demo,版本升级很容易有错误…,百度和Google

Uncaught TypeError: Cannot read property 'msie' of undefined1

谷歌:

jQuery.browser() removed

The jQuery.browser() method has been deprecated since jQuery 1.3 and is removed in 1.9. If needed, it is available as part of the jQuery Migrate plugin. We recommend using feature detection with a library such as Modernizr.

意思就是jQuery.browser()在后版本不支持了,需要引入一个js插件来进行兼容处理;好吧,在引入一个js文件就可以了: 
下载地址:jquery-migrate-1.3.0.js

下载这个js文件,然后放在jquery文件下面:

  <script src="jquery-2.1.4.js"></script>
  <script src="jquery-migrate-1.3.0.js"></script>12

原文链接


如以上无效,请参考以下链接: 
Uncaught TypeError: Cannot read property ‘msie’ of undefined - jQuery tools

//在代码中加上
<script type="text/javascript">
    jQuery.browser = {};
    (function () {
        jQuery.browser.msie = false;
        jQuery.browser.version = 0;
        if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
            jQuery.browser.msie = true;
            jQuery.browser.version = RegExp.$1;
        }
    })();
</script>


注:本文来源:转载,转载目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如有侵权行为,请联系我们,我们会及时删除。


评论