onclick事件跟踪不起作用

时间:2018-07-07 23:13:31

标签: javascript html

我有一个共享按钮,想跟踪onclick事件。按钮可以正常工作,但是当我添加onclick事件时,它会完全消失。

这是我的按钮的脚本,其中包括onclick:

<script type='text/javascript'>
//<![CDATA[
var siteurl = window.location.href;
  document.write('<div class="sharesimp"><div class="sharede"> \
\
<a class="fb social-popup" href="https://www.facebook.com/sharer/sharer.php?u=' + siteurl + '" target="_blank" title="Share to Facebook" onclick="_gaq.push(['_trackSocial', 'Facebook', 'Share', 'pageURL']);">\
    <i class="fa fa-facebook fbtea"></i> Share Facebook</a> \
 \
</div><div class="clear"></div></div> \
');
//]]>
</script>

1 个答案:

答案 0 :(得分:3)

之所以失败,是因为您使用单引号public void Add(T item) { if (_size == _items.Length) EnsureCapacity(_size + 1); _items[_size++] = item; _version++; } private void EnsureCapacity(int min) { if (_items.Length < min) { int newCapacity = _items.Length == 0? _defaultCapacity : _items.Length * 2; // Allow the list to grow to maximum possible capacity (~2G elements) before encountering overflow. // Note that this check works even when _items.Length overflowed thanks to the (uint) cast if ((uint)newCapacity > Array.MaxArrayLength) newCapacity = Array.MaxArrayLength; if (newCapacity < min) newCapacity = min; Capacity = newCapacity; } } 包围了整个字符串,因此您需要对内部的单引号'进行转义

'