Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 上出现意外的令牌错误_Javascript_Html - Fatal编程技术网

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用引号括起来。要么是
要么是
。谢谢,我做了标记,效果很好。