views:

890

answers:

3

I have the following Javascript libraries loaded for my page.

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="http://cdn.jquerytools.org/1.1.2/jquery.tools.min.js"&gt;&lt;/script&gt;
<script type="text/javascript" src="./js/jquery.scrollTo-min.js"></script>

I have the div element that I want to place them in:

<div class="content" id="content">
</div>

I have this link:

<a id="changeText" href="rules.html">Click to change</a>

Finally, I have the following jQuery code:

<script>

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

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

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

  console.log(url);

  $.scrollTo("0%", 400);
 });
});
</script>

This all works in Safari. The oddest part of the story is that it only works in Firefox when Firebug is on. When Firebug is NOT on, the page seems to be dynamically loaded, but then the page loads rules.html and switches to it, which is not my desired goal.

Also, of course, none of this works in IE8.

What am I doing wrong?

+8  A: 

Take out the console.log, it is undefined when firebug is not running.

Alex Sexton
I also needed to add:return false;at the end of my function. Otherwise the browser would load up rules.html
Tylo
Yeah, the console object only exists in Safari and Firefox when Firebug is on. You need to strip out the console.log call.
ohdeargod
And more generally: look in the Error Console to debug problems, it would've told you there was no console.log().
Nickolay
If you were to look _in_ the error console, wouldn't that automatically make the console.log work?
Alex Sexton
No. "Error console" refers to the built-in Error console in Firefox. It's not the Firebug equivalent. You can find it by pressing `Ctrl + Shift + J` or `Tools > Error Console` in Firefox.
S Pangborn
+8  A: 

You'd better wrap all your

console.log(...)

into

if (window.console) {
    console.log(...);
}
igorp1024
+1 I liked this answer as it offered a work-around which would allow both scenarios to function properly.
Kyle B.
I do something similar where i have a function called log() which will check if window.console is available and if so log the command.
Shard
A: 

Also there is interesting project called fauxconsole: Simulating a Firebug, Safari or Opera debugging console in Microsoft Internet Explorer with Faux Console

igorp1024