onclick事件的语法错误

时间:2017-04-21 12:18:59

标签: javascript google-analytics

我想将一些信息传输到我的Google Analytics帐户,以获取有关我网站的信息。但我有一个问题。我总是进入控制台:

Dim ind As Integer
Dim bl As Boolean
ind = 0
While ind < Forms!Rec!CONTACT.ListCount
bl = Forms!Rec!CONTACT.Selected(ind)
If bl Then
txt1 = txt1 + "Contact : " & Forms!Rec!CONTACT.Column(4, ind) & " " & Forms!Rec!CONTACT.Column(2, ind) & vbCrLf & Forms!Rec!CONTACT.Column(3, ind) & vbCrLf & Forms!Rec!CONTACT.Column(6, ind)
End If
ind = ind + 1
Wend

这是我的(index):2513 Uncaught SyntaxError: missing ) after argument list 行:

onclick=".."

但紧张的是它正在使用另一个功能:

<a onclick="googleAL(https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp, South Park The Fractured But Whole);" href="https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp" title="South Park The Fractured But Whole" class="btn btn-buy btn-sm btn-block" rel="nofollow" target="_blank">Kaufen*</a>

所以我认为,为什么它不起作用的原因必须是 googleAL函数:

<a onclick="fbPixels();" href="https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp" title="South Park The Fractured But Whole" class="btn btn-buy btn-sm btn-block" rel="nofollow" target="_blank">Kaufen*</a>

但我的错误在哪里? - 为什么抛出这一行是错误的?我没有错误...

该功能甚至无法被调用......我知道,因为我没有得到警报。这一行的错误在哪里?

googleAL功能如下:

onclick="googleAL(https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp, South Park The Fractured But Whole);"

问候,谢谢!

2 个答案:

答案 0 :(得分:3)

字符串值需要用引号括起来。

所以不要这样:

googleAL(http://...)

你想要这个:

googleAL('http://...')

在这种情况下,每个参数都是它自己的字符串:

googleAL('http://...', 'South Park...')

答案 1 :(得分:0)

尝试使用正确的语法。

你应该用引号括起来,但现在有字符串。 如果您想更改数据类型,请在javascript中更改为您的函数。

<a onclick="googleAL('https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp', 'South Park The Fractured But Whole');" href="https://www.gamesdeal.com/south-park-the-fractured-but-whole-pc.html?___store=english?a_aid=gmkshp" title="South Park The Fractured But Whole" class="btn btn-buy btn-sm btn-block" rel="nofollow" target="_blank">Kaufen*</a>