admin管理员组

文章数量:1278886

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

<a class="question helpcenterheading" href="">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)

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

<a class="question helpcenterheading" href="http://www.google.">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)

Share Improve this question edited May 31, 2014 at 14:55 Barmar 782k56 gold badges546 silver badges660 bronze badges asked May 31, 2014 at 14:48 user2439720user2439720 212 silver badges3 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 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.

You have

<body onload="prettyPrint()">

But prettyPrint is never defined

本文标签: javascriptReferenceError prettyPrint is not defined errorStack Overflow