Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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 在jQuery中,知道何时单击facebook按钮_Javascript_Jquery_Facebook_Iframe - Fatal编程技术网

Javascript 在jQuery中,知道何时单击facebook按钮

Javascript 在jQuery中,知道何时单击facebook按钮,javascript,jquery,facebook,iframe,Javascript,Jquery,Facebook,Iframe,所以在我的页面上,我嵌入了Facebook,就像这样: 这是它输出的代码 <div class="facebook"> <div id="fb-root" class=" fb_reset"> <div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div> <iframe scrolling="no" framebor

所以在我的页面上,我嵌入了Facebook,就像这样:

这是它输出的代码

<div class="facebook">          
 <div id="fb-root" class=" fb_reset">
  <div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div>

  <iframe scrolling="no" frameborder="0" name="fb_xdm_frame_http" allowtransparency="true" id="fb_xdm_frame_http" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tab-index="-1" style="border: medium none;" src="http://static.ak.facebook.com/connect/xd_arbiter.php?version=24#channel=f194f0214c1b73&amp;origin=http%3A%2F%2Fqantascu.dev.com&amp;channel_path=%2Fabout.html%3Ffb_xd_fragment%23xd_sig%3Df1bc3676c1f570e%26"></iframe>    

  <iframe scrolling="no" frameborder="0" name="fb_xdm_frame_https" allowtransparency="true" id="fb_xdm_frame_https" aria-hidden="true" title="Facebook Cross Domain Communication Frame" tab-index="-1" style="border: medium none;" src="https://s-static.ak.facebook.com/connect/xd_arbiter.php?version=24#channel=f194f0214c1b73&amp;origin=http%3A%2F%2Fqantascu.dev.com&amp;channel_path=%2Fabout.html%3Ffb_xd_fragment%23xd_sig%3Df1bc3676c1f570e%26"></iframe>

  </div>
 </div>
<div style="position: absolute; top: -10000px; height: 0px; width: 0px;"><div></div></div></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
    <fb:like colorscheme="light" action="recommend" show_faces="false" width="200" layout="button_count" send="true" href="http://qantascu.dev.com/about.html" fb-xfbml-state="rendered" class="fb_edge_widget_with_comment fb_iframe_widget"><span style="height: 20px; width: 166px;">
<iframe scrolling="no" id="f21dc10b55b8de4" name="f14dd27ab0fc5" style="border: medium none; overflow: hidden; height: 20px; width: 166px;" title="Like this content on Facebook." class="fb_ltr" src="http://www.facebook.com/plugins/like.php?api_key=&amp;locale=en_US&amp;sdk=joey&amp;channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter.php%3Fversion%3D24%23cb%3Df314d5a8f7b12c6%26origin%3Dhttp%253A%252F%252Fqantascu.dev.com%252Ff194f0214c1b73%26domain%3Dqantascu.dev.com%26relation%3Dparent.parent&amp;href=http%3A%2F%2Fqantascu.dev.com%2Fabout.html&amp;node_type=link&amp;width=200&amp;layout=button_count&amp;colorscheme=light&amp;action=recommend&amp;show_faces=false&amp;send=true&amp;extended_social_context=false"></iframe></span></fb:like></div>

这是行不通的。

有一种非常简单的方法可以实现你想要的。Facebook提供了
FB.Event.subscribe
,您可以使用它将处理程序附加到事件,并在事件触发时调用回调。引用这个例子,当用户喜欢某样东西时,就会回调

FB.Event.subscribe('edge.create',
  function(response) {
    alert('You liked the URL: ' + response);
  }
);
引用有关边的信息。创建此处使用的

edge.create-当用户喜欢某样东西时触发(fb:like)。回调函数的响应参数包含以下URL: “”

请看这个:
FB.Event.subscribe('edge.create',
  function(response) {
    alert('You liked the URL: ' + response);
  }
);