我为我的页面加载了以下 Javascript 库。
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jquerytools.org/1.1.2/jquery.tools.min.js"></script>
<script type="text/javascript" src="./js/jquery.scrollTo-min.js"></script>
我有要放置它们的 div 元素:
<div class="content" id="content">
</div>
我有这个链接:
<a id="changeText" href="rules.html">Click to change</a>
最后,我有以下 jQuery 代码:
<script>
$(document).ready(function() {
$("#changeText").click(function(){
var url = $(this).attr("href");
$("#content").load(url);
console.log(url);
$.scrollTo("0%", 400);
});
});
</script>
这一切都适用于 Safari。这个故事最奇怪的部分是,它仅在 Firebug 打开时在 Firefox 中运行。当Firebug未打开时,页面似乎是动态加载的,但随后页面加载rules.html并切换到它,这不是我想要的目标。
当然,这些在 IE8 中都不起作用。
我做错了什么?
最佳答案
你最好把你的所有东西都包起来
console.log(...)
进入
if (window.console) {
console.log(...);
}
关于javascript - 当 Firebug 运行时,jQuery 在 Firefox 中工作,当 Firebug 未运行时,jQuery 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1596836/