Javascript 上出现意外的令牌错误
我在下面的脚本中遇到错误。它显示Javascript 上出现意外的令牌错误,javascript,html,Javascript,Html,我在下面的脚本中遇到错误。它显示未捕获的语法错误:意外标记: 我不知道这是为什么,也不知道我错过了什么 <script> //[CDATA[ if (%%GLOBAL_Availability%% == "") {'error is here document.getElementById("ShopButton").style.display = "block"; document.querySelector("#ShopButton").addEv
未捕获的语法错误:意外标记:
我不知道这是为什么,也不知道我错过了什么
<script> //[CDATA[
if (%%GLOBAL_Availability%% == "") {'error is here
document.getElementById("ShopButton").style.display = "block";
document.querySelector("#ShopButton").addEventListener("click",function(){
window.location.href='%%GLOBAL_Availability%%';
},false);
}
//]]> </script>
/[CDATA[
如果(%%GLOBAL_Availability%%==“”){此处有错误
document.getElementById(“ShopButton”).style.display=“block”;
document.querySelector(“ShopButton”).addEventListener(“单击”,函数(){
window.location.href='%%全局可用性%';
},假);
}
//]]>
以下是它在Chrome上的显示方式:
非常感谢您的帮助。错误是因为您没有将
%%GLOBAL\u Availability%%
放在引号内
if ('%%GLOBAL_Availability%%' == "") {
document.getElementById("ShopButton").style.display = "block";
document.querySelector("#ShopButton").addEventListener("click",function(){
window.location.href='%%GLOBAL_Availability%%';
},false);
}
我不知道你所说的%%全球可用性%%
是什么意思。它不是有效的变量名,也不是有效的url
变量名必须以$、\或Unicode类别“大写字母(Lu)”、“小写字母(Ll)”、“标题字母(Lt)”、“修饰符字母(Lm)”、“其他字母(Lo)”或“字母编号(Nl)”中的任何字符开头
字符串的其余部分可以包含相同的字符,加上任何U+200C零宽度非连接字符、U+200D零宽度连接字符以及Unicode类别中的字符“非间距标记(Mn)”、“间距组合标记(Mc)”、“十进制数字(Nd)”或“连接器标点(Pc)”
您希望
%%%GLOBAL\u Availability%%
返回什么?您需要将Url用引号括起来。要么是“
要么是”
。谢谢,我做了标记,效果很好。