单击类似按钮时显示消息?

编程入门 行业动态 更新时间:2024-10-12 05:52:57
本文介绍了单击类似按钮时显示消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用以下代码在用户点击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>

更多推荐

单击类似按钮时显示消息?

本文发布于:2023-11-11 05:28:54,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1577510.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单击   按钮   类似   消息

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!