当Firebug运行时,jQuery在Firefox中运行,当Firebug未运行时不起作用

Tyl*_*ylo 17 javascript firefox jquery firebug

我为我的页面加载了以下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>
Run Code Online (Sandbox Code Playgroud)

我有div元素,我想把它们放在:

<div class="content" id="content">
</div>
Run Code Online (Sandbox Code Playgroud)

我有这个链接:

<a id="changeText" href="rules.html">Click to change</a>
Run Code Online (Sandbox Code Playgroud)

最后,我有以下jQuery代码:

<script>

$(document).ready(function() {
 $("#changeText").click(function(){

  var url = $(this).attr("href");

  $("#content").load(url);

  console.log(url);

  $.scrollTo("0%", 400);
 });
});
</script>
Run Code Online (Sandbox Code Playgroud)

这一切都适用于Safari.这个故事中最奇怪的部分是它只能在Firebug启动时在Firefox中运行.当Firebug未启用时,页面似乎是动态加载的,但页面加载rules.html并切换到它,这不是我想要的目标.

当然,这也不适用于IE8.

我究竟做错了什么?

igo*_*024 29

你最好包装你的所有

console.log(...) 
Run Code Online (Sandbox Code Playgroud)

if (window.console) {
    console.log(...);
}
Run Code Online (Sandbox Code Playgroud)

  • 我做了类似的事情,我有一个名为log()的函数,它将检查window.console是否可用,如果是,请记录命令. (4认同)

Ale*_*ton 11

取出console.log,当firebug没有运行时,它是未定义的.