ReferenceError: prettyPrint is not defined error

6.7k Views Asked by At

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)

2

There are 2 best solutions below

0
On

You have

<body onload="prettyPrint()">

But prettyPrint is never defined

0
On

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.