在我的sharepoint网站上的所有网页中,我有 1 页面需要使用...
jQuery工具& videolightbox& jQuery 1.3.2(所有包!)。
网站的其余部分正在使用jQuery 1.8.3
但是在同一页面上,标题,菜单和页脚需要使用jQuery 1.8.3才能正常运行。这是我发生冲突的地方,也是我头痛的地方。
在这个单一/冲突的页面上,我怎样才能防止jQuery 1.3.2与我在自定义脚本中加载的任何其他jQuery 1.8.3方法和函数发生冲突? site.js文件?
下面是我的代码如何在主模板底部设置的演示...
<!--THESE 2 FILES WORK GREAT FOR THE ENTIRE SITE-->
<script src=".../jquery-1.8.3.min.js" type="text/javascript"></script>
<script type="text/javascript" src=".../custom-scripts-for-the-whole-site.js"></script>
<script type="text/javascript">
/*THIS SECTION LOADS JQUERY 1.3.2 IN ORDER FOR JQUERY TOOLS AND VIDEOLIGHTBOX TO WORK
JQUERY TOOLS BUNDLES 1.3.2 WITHIN IT'S OWN FILE! - FYI
I SET UP A CONDITIONAL STATEMENT TO LOAD THIS CODE ONLY ON THIS SPECIFIC PAGE.
*/
var mLof = document.getElementById("donate-landing-page");
if(mLof !=null) {
document.write(unescape("%3Cscript src='/jquery.tools.min.live.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/swfobject.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/videolightbox.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/jquery.easing.1.3.js' type='text/javascript'%3E%3C/script%3E"));
}
//*/
</script>
感谢您的任何建议!
答案 0 :(得分:0)
您需要$.noConflict
API
<script type="text/javascript">
/*THIS SECTION LOADS JQUERY 1.3.2 IN ORDER FOR JQUERY TOOLS AND VIDEOLIGHTBOX TO WORK
JQUERY TOOLS BUNDLES 1.3.2 WITHIN IT'S OWN FILE! - FYI
*/
var mLof = document.getElementById("donate-landing-page");
if(mLof !=null) {
document.write(unescape("%3Cscript src='/jquery.tools.min.live.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/swfobject.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/videolightbox.js' type='text/javascript'%3E%3C/script%3E"));
document.write(unescape("%3Cscript src='/jquery.easing.1.3.js' type='text/javascript'%3E%3C/script%3E"));
jq132 = $.noConflict(true);
}
//*/
</script>