Uncaught TypeError: Cannot read property 'msie' of undefined

时间:2022-08-24 13:55:45

1、错误描述

Uncaught TypeError: Cannot read property 'msie' of undefined
    at Object._show (http://localhost:8080/cmp/js/jquery.hiAlerts-min.js:41:72)
    at Object.alert (http://localhost:8080/cmp/js/jquery.hiAlerts-min.js:2:317)
    at hiAlert (http://localhost:8080/cmp/js/jquery.hiAlerts-min.js:84:34)
    at HTMLButtonElement.<anonymous> (http://localhost:8080/cmp/js/page/index.js:62:4)
    at HTMLButtonElement.dispatch (http://localhost:8080/cmp/js/jquery-1.11.0.min.js:3:8066)
    at HTMLButtonElement.r.handle (http://localhost:8080/cmp/js/jquery-1.11.0.min.js:3:4767)
Uncaught TypeError: Cannot read property 'msie' of undefined

2、错误原因

      由于jquery 1.9以及以上版本不支持$.browser.msie和$.browser.version这两个方法,而页面引入的是jquery-1.11.0.min.js,版本比1.9更高,不支持上述两个方法,导致出现这个错误


3、解决办法

     将if条件判断

if ( a.browser.msie && parseInt(a.browser.version) <= 6)) {
      c = c + a(window).scrollTop()
}
if (a.browser.msie && parseInt(a.browser.version) <= 6)) {
      b = b - 175
}
     修改为

if ( 'undefined' == typeof(document.body.style.maxHeight)) {
      c = c + a(window).scrollTop()
}
if ('undefined' == typeof(document.body.style.maxHeight)) {
      b = b - 175
}