我有:
<!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>
现在,问题是 Regular-Visitors-&-Ops.html 页面无法加载,但它正在加载!所以我修改了我的撤消操作,直到我发现不包括 prototype.js 让该链接通过 jquery bbq 的方式工作。
什么给了?如何让 prototype.js 和 jquery bbq 共存?我需要两者来做不同的事情..
要启动并运行它,您需要在同一目录中添加一个额外的 Regular-Visitors-&-Ops.html 文件,例如:
<!DOCTYPE html>
<head>
</head>
</body>
this is the additional file.
</body>
</html>
以及jquery,jquery bbq的两个脚本(我自己命名的一个),& prototype.js。
现在,如果您确实进行了设置 - 外卖原型(prototype)和 Regular-Visitors(...) 链接有效。问题是,我正在使用 prototype.js。所以要么我如何让这两个工作,或者更容易地,我如何实现 scrollTo 函数(不能使用 anchor ,因为 jquery bbq 占用了 anchor /哈希(例如“index.html# 中的“#welcome”欢迎”) WITHOUT USING PROTOTYPE.JS?应该有一个吧?
最佳答案
通过在 jQuery 之后包含 prototype.js,Prototype 将覆盖全局 $
变量的值。你只需要使用:
var $j = jQuery.noConflict();
然后您可以在 jQuery 上下文中使用 $j
代替 $
,在原型(prototype)上下文中使用 $
。这是文档:http://api.jquery.com/jQuery.noConflict/ .
关于javascript - 为什么包含 prototype.js 会破坏 jquery bbq 的功能?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8907588/