开发者

Firebug syntax error

test.html:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHT开发者_开发知识库ML 1.1//EN"
                      "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd"
      xml:lang="en">
  <head><title>Test</title></head>
  <body>
    <script language="javascript" type="text/javascript" src="test.js"></script>
  </body>
</html>

test.js:

var a = 4;

Firebug:

syntax error
var a = 4;
 ^


Your file probably has some hidden character which is causing the problem. Create a new file and try again.


Remove the language="javascript" it is not XHTML valid!

Add also a character encoding meta tag.

<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />


I've seen that kind of error show up when the DTD is incorrect, or the page doesn't quite validate with that DTD. It's totally unintuitive, but try it out.


Some encoding problem? UTF with BOM? Create a new plain txt file and rename it to test.js and write(!) in the code again.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜