未终止字符串文字的常见来源 [英] Common sources of unterminated string literal

查看:43
本文介绍了未终止字符串文字的常见来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试调试在 Firefox 扩展中读取并执行的 JavaScript 脚本.我只能通过 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆