SyntaxError: Invalid character '\u0008' message from the DOCTYPE tag

别来无恙 提交于 2019-12-11 14:07:50

问题


I am setting up a server and am getting a strange error I have never seen before:

It is complaining about line 1 in the source, but that is just the DOCTYPE tag!

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <!-- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> -->
    ...

As you can see I already tried setting the Content-Type to be something other than utf-8. What is happening here?


回答1:


The actual cause of the error is not located at line 1. For example, using eval also causes errors to be reported at line 1.

Look in your source code for the BACKSPACE U+0008 character. A method to spot this invisible character is described here.




回答2:


What happens if you add an comment on line1?

<!--empty line for the fun of it-->
<!DOCTYPE HTML>


来源:https://stackoverflow.com/questions/10353468/syntaxerror-invalid-character-u0008-message-from-the-doctype-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!