Chrome 未捕获语法错误:意外标记 <

发布于 2024-09-08 12:41:26 字数 281 浏览 4 评论 0 原文

尝试使用 cdata 存储 css 但 chrome 抛出“Uncaught SyntaxError: Unexpected token <”对于下面的第一行:

var default_style = <![CDATA[
    .TTContent table td.Mission img { max-height: 15px;}
]]>.toXMLString();

有谁知道为什么?

PS实际上CSS要长得多

非常感谢,

Trying to use cdata to store css but chrome throws "Uncaught SyntaxError: Unexpected token <" for the first line below:

var default_style = <![CDATA[
    .TTContent table td.Mission img { max-height: 15px;}
]]>.toXMLString();

Does anyone knows why?

P.s. the css is much longer in reality

Many thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

最美的太阳 2024-09-15 12:41:26

Chrome 不支持 E4X。你只能希望在 Firefox 中做到这一点(我想在你稍微修正一下你的语法之后)。

code.google.com/p/v8/issues/detail?id=235 --“目前没有在 V8 中实现 E4X 的计划”

该代码对于 Firefox 也是不正确的:

Firefox 至少要求将其包装在 XMLList 中: var default_style = <>.toXMLString();

Chrome has no E4X support. You can only hope to do this in Firefox (after you fix your syntax a bit I think).

code.google.com/p/v8/issues/detail?id=235 -- "There are currently no plans for implementing E4X in V8"

The code is also incorrect for Firefox:

Firefox at least requires it to be wrapped in an XMLList: var default_style = <><![CDATA[ .TTContent table td.Mission img { max-height: 15px;} ]]></>.toXMLString();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文