SCRIPT1010: Expected identifier in IE10

2020-07-06 04:45发布

问题:

In my project I am using the Prototype JavaScript Framework 1.7.1

When I load the web page in IE10 on Windows 7 I get the error message below: SCRIPT1010: Expected identifier line 1 character 9 which points to <!DOCTYPE html> in my test HTML page below:

<!DOCTYPE html>
<html>
<head>
 <title>My webpage title</title>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <meta http-equiv="X-UA-Compatible" content="IE=edge" />
 <meta name="description" content="" />
 <meta name="keywords" content="" />
 <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/prototype/1.7.1.0/prototype.js'></script>
</head>
<body>
    just testing
</body>
</html>

HTTP Request Header

GET /test.html HTTP/1.1[CRLF]
Host: www.mydomain.com[CRLF]
Connection: close[CRLF]
User-Agent: Web-sniffer/1.0.44 (+http://web-sniffer.net/)[CRLF]
Accept-Encoding: gzip[CRLF]
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8[CRLF]
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6[CRLF]
Accept-Charset: ISO-8859-1,UTF-8;q=0.7,*;q=0.7[CRLF]
Cache-Control: no-cache[CRLF]
Referer: http://web-sniffer.net/[CRLF]

HTTP Response Header

Name    Value   Delim
Status: HTTP/1.1 200 OK
Server: webhost 
Date:   Tue, 26 Mar 2013 10:07:56 GMT   
Content-Type:   text/html   
Transfer-Encoding:  chunked 
Connection: close   
Vary:   Accept-Encoding,User-Agent  
Last-Modified:  Tue, 26 Mar 2013 10:07:29 GMT   
Cache-Control:  max-age=3600, public, must-revalidate, proxy-revalidate 
Expires:    Tue, 26 Mar 2013 11:07:56 GMT   
Pragma: public  
CF-RAY: 553096521a6047f 
Content-Encoding:   gzip

Does anyone know what is causing this error or is this a bug in Prototype 1.7.1?

回答1:

See this pull request on Github https://github.com/sstephenson/prototype/pull/93

PrototypeJS does some feature detection everytime it loads and Internet Explorer 10 has adjusted the way some of the Javascript syntax is parsed and throws that error.

PrototypeJS is doing a detection to see how to handle passing functions as tag attributes (like an onclick method) and the IE10 javascript parser detects that as a syntax error.

If you look at the pull request in Github it will show you a band-aid as well as a full fix to make Internet Explorer 10 happy.

Please spread the word.

2013-05-17 UPDATE The pull request referenced has been closed and a fix has been integrated into the the master branch of the PrototypeJS github

https://github.com/sstephenson/prototype

Please clone from there and update your scripts.

2014-05-01 UPDATE The fix for this has been released in PrototypeJS 1.7.2

http://prototypejs.org/2014/04/18/prototype-1-7-2/