SCRIPT1014:无效字符 - 引用符号 [英] SCRIPT1014: Invalid character - Quote symbol

查看:1571
本文介绍了SCRIPT1014:无效字符 - 引用符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个问题:

array [i] .idAuthor是一个String变量。我想将此String传递给一个在append-String中调用的函数。

array[i].idAuthor is a String variable. I want to pass this String to a function which is called inside an append-String.

除了Internet Explorer,代码在Chrome和Firefox中运行良好。 IE给了我这个错误:SCRIPT1014:无效字符

The code works fine in Chrome and Firefox except for Internet Explorer. IE gives me this error: SCRIPT1014: Invalid character

我认为问题是`-Quotes

我希望以下示例有助于表达我的问题。

I hope the following example helps to express my problem.

<script>
(...)
    $("#id").append("<div onClick='myFunc(`" + array[i].idAuthor + "`);'>" + i + "</div>");
(...)
<script>

还有另一种方法来处理我的情况或将`-Quotes替换为兼容的另一个字符与IE?

Is there another way to handle my situation or to replace the `-Quotes with another character that is compatible with IE?

推荐答案

看起来你正在将反引号(`)放入你的字符串中。

It looks like you're putting backticks (`) into your string there.

onClick='myFunc(`" + ... + "`);'>

在现代浏览器中,反引号用于模板文字。 IE11不支持模板文字。

In modern browsers, backticks are used for template literals. IE11 doesn't support template literals.

相反,尝试转义你的报价:

Instead, try escaping your quotes:

onClick='myFunc(\"" + array[i].idAuthor + "\");'>

这篇关于SCRIPT1014:无效字符 - 引用符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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