常见的未终结字符串文字来源 [英] Common sources of unterminated string literal
问题描述
我正在尝试调试一个JavaScript脚本,该脚本在Firefox扩展中被读取并被执行。我只能通过Firebug控制台看到错误(我的代码对Firebug是不可见的),它报告了一个未终止的字符串文字。
I am trying to debug a JavaScript script that gets read in a Firefox extension and executed. I only can see errors via the Firebug console (my code is invisible to Firebug), and it's reporting a "unterminated string literal."
我检查了这条线和它周围的线条,一切看起来都很细,括号,大括号和引号都是平衡的。我应该看的其他可能的原因为了?
I checked the line and the lines around it and everything seems fine-parentheses, braces, and quotes are balanced, etc. What are other possible causes that I should be looking for?
推荐答案
大多数浏览器似乎都有这样的代码问题:
Most browsers seem to have problems with code like this:
var foo = "</script>";
在Firefox,Opera和IE8中,会导致无终止的字符串字面值错误。当序列化包含脚本的html代码时,可能非常讨厌。
In Firefox, Opera and IE8 this results in an unterminated string literal error. Can be pretty nasty when serializing html code which includes scripts.
这篇关于常见的未终结字符串文字来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!