0

Hope you can help me with ReferenceError: prettyPrint is not defined.

<a class="question helpcenterheading" href="http://www.google.com">How do I contact you?</a>
<span class="answer">One moment...</span>

<script>
$(document).ready(function() {
    $("span.answer").hide();
    $("a.question").click(function() {
        $(this).toggleClass("active").next().slideToggle(2000, function() {
            window.location.href = $(this).attr('href');
        });
        return false;
    });
});
</script>

(live version)

Barmar
  • 741,623
  • 53
  • 500
  • 612
user2439720
  • 21
  • 2
  • 3

2 Answers2

7

According to the Documentation there are two ways to run Prettify:

1) The auto-loader run_prettify.js. This doesn't require you to call any functions, you can specify some parameters in the URL.

2) Serving your own JS and CSS, by loading prettify.css and prettify.js. Then you need to use <body onload="prettyPrint()">.

I think you're using the auto-loader, and then trying to call prettyPrint(). Pick one or the other method, you can't mix them.

Barmar
  • 741,623
  • 53
  • 500
  • 612
5

You have

<body onload="prettyPrint()">

But prettyPrint is never defined

etherous
  • 709
  • 4
  • 10