Programing

잡히지 않은 TypeError : 정의되지 않은 'msie'속성을 읽을 수 없습니다-jQuery 도구

lottogame 2020. 5. 17. 10:30
반응형

잡히지 않은 TypeError : 정의되지 않은 'msie'속성을 읽을 수 없습니다-jQuery 도구


Chrome 개발자 콘솔에서 다음 오류가 발생합니다.

Uncaught TypeError: Cannot read property 'msie' of undefined

내 이해는 그것이 .browserjQuery에서 더 이상 사용되지 않기 때문에 최신 버전의 jQuery 도구를 사용하고 있으며 여전히 오류를 발생 js시키는 것입니다. 파일을 확인하면 파일이 있습니다.

오류가 발생하지 않도록 어떻게 해결할 수 있습니까?


$.browser방법은 jQuery 1.9부터 제거되었습니다.

jQuery.browser() removed

jQuery.browser()메소드는 jQuery 1.3부터 ​​더 이상 사용되지 않으며 1.9에서 제거되었습니다. 필요한 경우 jQuery Migrate 플러그인의 일부로 사용할 수 있습니다. Modernizr과 같은 라이브러리에서 기능 감지를 사용하는 것이 좋습니다.

jQuery Core 1.9 업그레이드 안내서 .

업그레이드 안내서에 명시된 바와 같이 jQuery Migrate 플러그인사용 하여이 기능을 복원하고 jQuery 도구가 작동하도록 할 수 있습니다.


AJ에서이 솔루션을 확인할 수 있습니다. 다음 코드를 복사하여 붙여 넣기 만하면됩니다.

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;
    }
})();

참고 :


jsp / js 파일에서 다음 스크립트 태그를 사용하십시오.

<script src="http://code.jquery.com/jquery-1.9.0.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>

이것은 확실히 작동합니다.


js 파일 포함 후 아래 코드를 사용하고 현재 작동합니다.

<script src="js/jquery-ui.min.js" type="text/javascript"></script>
<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>

다음은 GitHub의 jQuery 도구 버그입니다 . 패치 중 하나를 시도 할 수 있습니다.

편집 -jQuery Tools가 많은 지원을 받고있는 것처럼 보이지 않습니다. 본인이 직접 지원할 준비가되지 않은 한 개인적으로 해당 라이브러리에 종속 된 새 프로젝트를 시작하지 않을 것입니다.


JS를 다음으로 교체하십시오

<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>

소스 링크


나는 단순히 추가했다

jQuery.browser = {
    msie: false,
    version: 0
};

더 이상 IE에 신경 쓰지 않기 때문에 jquery 스크립트 후에.


이전 MS IE 버전을 전혀 지원할 계획이 없으므로 모든 참조를로 대체 browser.msie했습니다 false. 좋은 해결책은 아니지만 나에게 효과적입니다.

실제로 !browser.msie는 조건에서 생략 될 수있는로 표시됩니다.


타격처럼 사용

$(function (a) {

. . . . 그런 다음 함수에서 msie 속성을 사용할 수 있습니다

if (a.browser.msie) 
{
}
else 
{
   $(settings.current).after(Uploadelement);
}

행운을 빕니다


타격처럼 사용

나는이 명령을 사용하고 해결

"Uncaught TypeError : undefined의 'msie'속성을 읽을 수 없습니다"오류

if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    return;
}

JQuery 1.10 및 JQuery UI 1.8을 사용하는 동안이 오류가 발생했습니다. 최신 JQuery UI 1.11.4로 업데이트하여이 오류를 해결할 수있었습니다.

Visual Studio에서 JQuery UI를 업데이트하는 단계 :

  • 프로젝트 또는 솔루션으로 이동
  • Right click: "Manage NuGet Packages"
  • On the left, click on "Installed Packages" tab
  • Look for "JQuery UI (Combined library)" and click Update
  • If found, Select it and click Update
  • If not found, find it in "Online > nuget.org" tab on the left and click install. If the old version of Jquery UI version is still existing, it can be deleted from the project

If you have jQuery defined twice, then you could get this error. For example, if you are working with Primefaces (it already includes jQuery) and you define it in other place.

참고URL : https://stackoverflow.com/questions/14923301/uncaught-typeerror-cannot-read-property-msie-of-undefined-jquery-tools

반응형