gpt4 book ai didi

javascript - 字符串文字在 Chrome、Firefox 中导致 "Unexpected token ILLEGAL"

转载 作者:行者123 更新时间:2023-11-30 07:05:35 25 4
gpt4 key购买 nike

这是在 Firefox 和 Chrome 中导致错误的完整文档:

<!DOCTYPE html>
<html>
<head>
<script>
var strs = [], scripts = ['harbl.js'], s = 0;
strs.push('<script src="' + scripts[s] + '"></script>');
</script>
</head>
<body>
<p>buh...</p>
</body>
</html>

http://jsfiddle.net/cryptoquick/J4zZT/

我得到的错误是:

Uncaught SyntaxError: Unexpected token ILLEGAL 

这让我很困惑。

最佳答案

</script>文字由浏览器解析,因为它在遍历代码时不知道上下文。你必须像这样逃避它:<\/script> .这是一个已知问题。

关于javascript - 字符串文字在 Chrome、Firefox 中导致 "Unexpected token ILLEGAL",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12679028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com