试图解决Jquery Libraries 1.8.2和JQuery之间的JQuery冲突问题。 1.4.4使用各种Stackoverflow线程中描述的所有方法。但是徒劳无功。
<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/
答案 0 :(得分: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);
}
},