Javascript error opening page - Uncaught Syntaxerror

Asked

Viewed 147 times

3

When I open the page it breaks and when I open the browser console appears the following error:

Uncaught SyntaxError: Unexpected token ;

When I see the code on the console it appears this way:

if (linhaAnterior$.size() > 0) {}

But my code is actually like this:

if (linhaAnterior$.size() > 0) {}

I have others ifs in this code but only this one changes when I open the page.

  • 3

    Your tag of <script/> should contain the attribute type="text/javascript"! Another thing, who handles the output for the browser? It seems that the > are being converted to its HTML entity...

  • I put the attribute but the message remains the same

  • 1

    The attribute was an observation to avoid problems, not exactly "the" solution! The question I asked you is that it can help me to help you :) (see my previous comment)

1 answer

2


As you are using XHTML, you need to encapsulate javascript code with CDATA, as per the excerpt below:

    <script type="text/javascript">
    // <![CDATA[
        ...
    // ]]>
    </script>

However, it is recommended to separate the javascript code into another file:

    <script type="text/javascript" src="/pasta/script.js"></script>

To learn more, see http://en.wikipedia.org/wiki/XHTML.

  • So, I had first put javascript code this way but the error remains the same.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.