本文介绍了单击类似按钮时显示消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用以下代码在用户点击facebook like按钮时提醒用户。它仅在Opera浏览器上提醒用户。如何解决此问题并使其适用于所有浏览器?
I am using the following code to alert the user when he click the facebook like button. It is alerting the user only on Opera browser. How do I fix this problem and make it work with all browsers ?
<script> FB.Event.subscribe('edge.create', function(response) { alert("You liked the URL"); } ); </script>我也可以使用Jquery。
I can also use Jquery.
推荐答案你把这段代码放在哪里了?
Where did you put this code ?
对我来说,你必须把它放在init中,如下所示: / p>
For me you have to put this in the init like this :
window.fbAsyncInit = function() { FB.init({ appId : APP_ID, status : true, cookie : true, xfbml : true }); FB.Event.subscribe('edge.create', function(response) { alert("You liked the URL"); } ); };如果你已经调用了FB.init,你必须使用这样的技巧:
If you have already call the FB.init, you have to use a trick like this :
<script type="text/javascript"> function hasFBLoad(){ if(FB != 'undefined'){ FB.Event.subscribe('edge.create', function(response) { alert("You liked the URL"); } ); }else{ setTimeout('hasFBLoad()', 200); } } hasFBLoad(); </script>更多推荐
单击类似按钮时显示消息?
发布评论