Intuit Anywhere脚本重新加载jQuery [英] Intuit Anywhere script reloading jQuery

查看:64
本文介绍了Intuit Anywhere脚本重新加载jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的应用程序加载jQuery 1.10.2,然后从Intuit加载 https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js 。任意脚本添加< script type =text / javascriptsrc =https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js> < / script> 到头部并重新加载jQuery。

Our application loads jQuery 1.10.2 and then loads https://appcenter.intuit.com/Content/IA/intuit.ipp.anywhere.js from Intuit. The anywhere script is adding <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js"></script> to the head and reloading jQuery.

这是擦除命名空间并破坏我们的大部分代码。脚本不应该看到jQuery已经加载了吗?我们如何防止重新加载jquery?

This is wiping the namespace and wrecking much of our code. Shouldn't the script see that jQuery is already loaded? How do we prevent jquery from being reloaded?

谢谢,
Forrest

Thanks, Forrest

推荐答案

编辑:



问题似乎是 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();
})();

这篇关于Intuit Anywhere脚本重新加载jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆