且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Intuit Anywhere脚本重新加载jQuery

更新时间:2023-12-04 23:43:16

编辑:



问题似乎是 window.jQuery.fn.jquery< 1.4.2返回false,因为'1.10.2'< '1.4.2'也将返回false。这是因为javascript会将其视为 1.1.2< 1.4.2 。另一种选择是删除 || window.jQuery.fn.jquery< 1.4.2

The problem seems to be that window.jQuery.fn.jquery < "1.4.2" returns false as '1.10.2' < '1.4.2' will also return false. It is because javascript will see it as 1.1.2 < 1.4.2. Another option is to remove the || window.jQuery.fn.jquery < "1.4.2"

如果您确定要包含jQuery,只需更改它附加脚本标记的代码的一部分。

If you are sure that you are including jQuery just change the part of the code where it appends the script tag.

在脚本的底部。更改

// function that starts it all. timeout is 0
(function() {
    // these are the domains whose js files we're going to look at
    // intuit.ipp.ourDomain = /(.intuit.com).*?#(.*)/;
    intuit.ipp.ourDomain = /intuit.com$/;
    if(window.jQuery === undefined || window.jQuery.fn.jquery < "1.4.2") {
        // minimum version 1.4.2
        var script_tag = document.createElement('script');
        script_tag.setAttribute("type","text/javascript");
        script_tag.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js");
        script_tag.onload = function () {
            if(window.jQuery) {
                intuit.ipp.jQuery = window.jQuery.noConflict(true);
                intuit.ipp.anywhere.windowLoad();
            }
        };
        script_tag.onreadystatechange = function () { // Same thing but for IE
            if (this.readyState == 'complete' || this.readyState == 'loaded') {
                script_tag.onload();
            }
        };

        // Try to find the head, otherwise default to the documentElement
        (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);

    } else {
        // we do have jquery
        intuit.ipp.jQuery = window.jQuery;
        intuit.ipp.anywhere.windowLoad();
    }
})();

// function that starts it all. timeout is 0
(function () {
    // these are the domains whose js files we're going to look at
    // intuit.ipp.ourDomain = /(.intuit.com).*?#(.*)/;
    intuit.ipp.ourDomain = /intuit.com$/;
    // we do have jquery
    intuit.ipp.jQuery = window.jQuery;
    intuit.ipp.anywhere.windowLoad();
})();