为什么包含prototype.js会破坏jquery bbq的功能



我有:

    <!DOCTYPE html>
<html>
<head>
    <title></title>

<link rel="stylesheet" type="text/css" href="/temp/css/menu.css" />
<link rel="stylesheet" type="text/css" href="/temp/css/bottomchatdiv.css" />
<link rel="stylesheet" type="text/css" href="/temp/css/centercontent.css" />
<link rel="stylesheet" type="text/css" href="/temp/css/basics.css" />

    <script type="text/javascript" src="jquery-1.7.js"></script>
<script type="text/javascript" src="jquery.ba-bbq.js"></script>
<script type="text/javascript" src="jquery.ba-bbq-addtl.js"> </script>
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript">
function getusto(anchorid) {
  $(anchorid).scrollTo();
} 
</script>
<script type="text/javascript" src="hide&show.js">
</script>


</head>
<body >

<div class="bbq">
  <div class="bbq-nav bbq-nav-top menu">
   <a class="mainitem menu_links" href="">Welcome</a>   <br> 
<a class="menu_links" href="#" onclick="getusto('welcome'); return false;">Welcome</a><br> 
<a class="menu_links" href="#" onclick="getusto('guidelines'); return false; ">Guidelines</a> 
<br>  
<hr style="width:48%"/>
<br>  

<a class="mainitem menu_links" href="#Regular-Visitors-&-Ops.html">Regulars & Ops</a> <br>
</div>
<br>  
<div class="bbq-content centercontent">
    <!-- This will be shown while loading AJAX content. You'll want to get an image that suits your design at http://ajaxload.info/ -->
        <div class="bbq-loading" style="display:none;">
      <img src="/shell/images/ajaxload-15-white.gif" alt="Loading"/> Loading content...
    </div>
    <!-- This content will be shown if no path is specified in the URL fragment. -->
    <div class="bbq-default bbq-item">
default welcome text here.
    </div>
  </div>

</div>

</body>
</html>

现在,问题是常客-Ops.html页面无法加载,但正在加载!所以我修改了我的undo,直到我发现不包括prototype.js让这个链接可以通过jquery-bq的方式工作。

什么东西?如何获得prototype.js&jquery bbq共存?我需要两者兼而有之。。

把这个弄起来&运行时,您需要一个额外的常客-&amp-Ops.html文件在同一目录中,比如:

<!DOCTYPE html>
<head>
</head>
</body>
this is the additional file.
</body>
</html>

除了jquery,jquery-bbq的两个脚本(我自己命名了一个),&prototype.js.

现在,如果你真的设置了这个外卖原型&常客(…)链接有效。问题是,我使用的是prototype.js。那么,我如何让这两个功能发挥作用,或者更容易的是,我如何在不使用prototype.js的情况下实现scrollTo函数(不能使用锚点,因为jquery bbq占用了锚点/散列(例如"index.html#welcome"中的"#welcome")?应该有一个对吧?

通过在jQuery之后包含prototype.js,prototype将覆盖全局$变量的值。你只需要使用:

var $j = jQuery.noConflict();

然后可以在jQuery上下文中使用$j来代替$,在原型上下文中可以使用$。以下是文档:http://api.jquery.com/jQuery.noConflict/.

jQuery和Prototype都使用$字符,因此它们会发生冲突。

如果你想同时使用它们,你需要使用jQuery的noConflict()方法将$alias释放回Protype

还有一个scrollTojQuery插件

最新更新