1

I keep getting an error in Firebug regarding the onClick event.

I've tried various different combinations of " and ' but to no avail. This worked fine before the onClick event was added.

Can anybody spot what I might be doing wrong?

addPhoneLogo: function (n) {
    if (i.phoneLogoLink.length > 1) var t = e('<span style="position:absolute; top:10px; right:10px;"><a onclick="ga('
    send ', '
    event ', '
    Call tracking ', '
    Click to call ', '
    Menufication ');"  href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    else var t = e('<span style="position:absolute; top:10px; right:10px;"><a href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    n.append(t)
},
0

3 Answers 3

1

Use escape character to add single quotes for onclick parameters : Use \' instead of '

addPhoneLogo: function(n) {
             if (i.phoneLogoLink.length > 1) var t = e('<span style="position:absolute; top:10px; right:10px;"><a onclick="ga(\'send\', \'event\', \'Call tracking\', \'Click to call\', \'Menufication\');"  href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
             else var t = e('<span style="position:absolute; top:10px; right:10px;"><a href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
             n.append(t)
         },
Sign up to request clarification or add additional context in comments.

Comments

1

Escape the ' by using \

addPhoneLogo: function (n) {
    if (i.phoneLogoLink.length > 1)
        var t = e('<span style="position:absolute; top:10px; right:10px;"><a onclick="ga(\'send \', \'event\',\'       Call tracking \', \'Click to call \', \'Menufication \');"  href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    else
        var t = e('<span style="position:absolute; top:10px; right:10px;"><a href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    n.append(t)
},

Comments

0
addPhoneLogo: function (n) {
    if (i.phoneLogoLink.length > 1)
        var t = e('<span style="position:absolute; top:10px; right:10px;"><a onclick="ga(\'send \', \'event\',\'       Call tracking \', \'Click to call \', \'Menufication \');"  href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    else
        var t = e('<span style="position:absolute; top:10px; right:10px;"><a href="' + phoneNum + '"><img src="' + i.phoneLogo + '" id="menufication-phone-logo" /></a></span>');
    n.append(t)
},

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.