Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/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
从html中的href标记调用javascript函数的另一种方法_Javascript_Jquery_Google Analytics_Internet Explorer 9 - Fatal编程技术网

从html中的href标记调用javascript函数的另一种方法

从html中的href标记调用javascript函数的另一种方法,javascript,jquery,google-analytics,internet-explorer-9,Javascript,Jquery,Google Analytics,Internet Explorer 9,我有这段代码,它在Chrome和Firefox上100%工作,但在IE9上不工作 <script> $(document).ready(function() { _gaq.push(['_trackEvent', 'Revenues', '<?php echo $tracking_event; ?>']); }); <a href="javascript;" onclick="_gaq.push(['_trackEvent', 'social', 'sh

我有这段代码,它在Chrome和Firefox上100%工作,但在IE9上不工作

 <script>
 $(document).ready(function() {
 _gaq.push(['_trackEvent', 'Revenues', '<?php echo $tracking_event; ?>']);
  });

<a href="javascript;" onclick="_gaq.push(['_trackEvent', 'social', 'share_fb']);
               window.open('https://www.facebook.com/sharer/sharer.php?
               u='+encodeURIComponent(location.href), 'facebook-share-dialog',
               'width=650,height=450');  return false;" class="os_new_icons_fb">

$(文档).ready(函数(){
_gaq.push([“跟踪事件”、“收入”和“]);
});

这是未经测试的。但是试着为链接设置一个监听器,而不是在html中定义JS。例如

<script>
   $('.my-class').click(function(e) {
      e.preventDefault();
      _gaq.push(['_trackEvent', 'social', 'share_fb']);
      window.open('https://www.facebook.com/sharer/sharer.php?u='+encodeURIComponent(location.href), 'facebook-share-dialog','width=650,height=450');
   });
</script>

$('.my class')。单击(函数(e){
e、 预防默认值();
_gaq.push([“跟踪事件”、“社交”、“共享fb”);
打开窗户https://www.facebook.com/sharer/sharer.php?u=“+encodeURIComponent(location.href),“facebook共享对话框”,“宽度=650,高度=450”);
});
然后你的html就可以了

<a href="#" class="my-class">CLICK HERE</a>


可能只是你问题中的一个输入错误。但是您缺少了结束标记。我知道它已经存在,很抱歉,我认为href=“javascript;”中的问题可能是IE9不支持它