-1

尝试使用各种 Stackoverflow 线程中描述的所有方法解决 Jquery 库 1.8.2 和 1.4.4 之间的 JQuery 冲突。但徒劳无功。

<script src="js/jquery-1.4.4.min.js" type="text/javascript"></script>
<script src="js/fshare.js" type="text/javascript"></script>
 <script type="text/javascript">
     $(document).ready(function () {
      $('#floating-bar').fshare({ theme: 'compact', upperLimitElementId:  'upper-limit-element', lowerLimitElementId: 'lower-limit-element' });
    });
</script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="./js/jquery-1.8.2.min.js">\x3C/script>')</script>

fshare.js 的链接:http: //egrappler.com/jquery-floating-social-share-plugin-floatshare/

4

1 回答 1

0

这里是 JQUERY 冲突的解决方案:

           var jQueryVersion = '1.11.2';
           var callback=function(isExists){
                    if (isExists) {
                        window.myJquery= jQuery.noConflict(true);

                    } else {                       
                        window.myJquery= $
                    }
                    console.log('local jQuery is loaded. Version: '.concat(window.myJquery.fn.jquery));
}
            jQueryCheck: function(callback) {

                var isExists = true;
                if (!window.jQuery || !$) {
                    isExists = false;
                    console.log('no jQuery on the site. Injecting JQUERY version: ' + jQueryVersion);
                }
                if (!isExists || window.jQuery().jquery !== jQueryVersion) {

                    var jQueryInstance = document.createElement('script');

                    jQueryInstance.type = 'text/javascript';
                    jQueryInstance.src = url_to_you_jquery_library
                    jQueryInstance.onload = function() {
                        callback(isExists);
                    };
                    jQueryGuavaInstance.onreadystatechange = function() {
                        if (this.readyState === 'complete') {
                            callback(isExists);
                        }
                    };
                    document.getElementsByTagName('head')[0].appendChild(jQueryInstance);
                    if (isExists) {
                        concole.log('jQuery exists on the site. Version: '.concat(window.jQuery().jquery));
                    }

                } else {
                    console.log('current site version is equals to newest jquery version. Site version: ' + window.jQuery().jquery + ', Latest JQUERY version: ' + jQueryVersion);
                }

            },
于 2015-10-18T12:21:38.127 回答