简体   繁体   English

我的Facebook页面被点赞后,如何添加重定向?

[英]How can I add a redirect for after my Facebook page is liked?

i have a web site which has some Facebook like buttons like below 我有一个网站,上面有一些类似Facebook的按钮,如下所示

<div class="like-box">
  <div class="fb-like" data-href="https://www.facebook.com/samebirthday.officialpage" data-width="500" data-layout="box_count" data-action="like" data-show-faces="true" data-share="false"></div>
</div>
<div id="fb-root"></div>

<script>
  //facebook
  (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/ja_JP/all.js#xfbml=1&appId=700721206653864";
    fjs.parentNode.insertBefore(js, fjs);
  }(document, 'script', 'facebook-jssdk'));
</script>

and then, how can I add a redirect for after my Facebook page is liked? 然后,如何在我的Facebook页面被赞后添加重定向? i tried this one, but it didn't work. 我尝试了这个,但是没有用。

<script type="text/javascript">
  window.fbAsyncInit = function() {
    FB.init({
      appId      : '700721206653864',
      status     : false, // check the login status upon init?
      cookie     : true, // set sessions cookies to allow your server to access the session?
      xfbml      : true  // parse XFBML tags on this page?
    });

    FB.Event.subscribe('edge.create',
      function(response) {
        alert('liked!');
      }
    );

    FB.Event.subscribe('edge.remove',
      function(response) {
        alert('unliked!');
      }
    );
  };
</script>
<script src='http://connect.facebook.net/ja_JP/all.js'></script>

Use the subscribe event of as edge.create, this is the event fired when someone likes the page using a Like button. 使用as edge.create的订阅事件,这是当有人使用“喜欢”按钮喜欢页面时触发的事件。 Add a redirect to it: 添加重定向到它:

FB.Event.subscribe('edge.create',
      function(response) {
        window.location.href = 'http://the_URL_you_want';
      }
    );

You need to add an EventListener on the and add it to the chain! 您需要在上添加一个EventListener并将其添加到链中!

` `

var flike = document.getElementById('-------'); var flike = document.getElementById('-------');

flike.addEventListener('click', function(){ flike.addEventListener('click',function(){

// here you can do the redirection //在这里您可以进行重定向

}, false); },错误); ` `

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过add.php(Facebook)添加页面后,如何将用户重定向到自定义网址 - how can i redirect a user to custom url after adding page through add.php (Facebook) 如何在Facebook的社交插件中查看用户是否喜欢Facebook页面? - How can i check if the person liked facebook page or not in social plugins of facebook? 如何在用户喜欢带有Facebook Like插件的页面后注销用户? - How to logout users after they have liked a page with the Facebook Like plugin? Facebook.streamPublish()完成后如何重定向? - How can I redirect after Facebook.streamPublish() has completed? 在Facebook中允许权限后如何重定向到页面 - How to redirect to page after allowing permission in Facebook Facebook的点击事件计数,例如父页面(我的页面)中的按钮(来自fb的iframe),而不是“喜欢”计数,我需要点击计数 - Click event count of the facebook like button(iframe from fb) in parent page(my page), not 'liked' count I need click count 检查用户是否喜欢Facebook页面 - Check if User liked Facebook page or not 如何检查用户是否已经喜欢了Facebook页面? - How to check IF user has ALREADY liked the facebook page? 如何在JavaScript中获得Facebook用户喜欢的页面名称,类别列表? - How to get facebook user liked page name, category list in javascript? 面子赞页面(新API) - facebook liked page (new API)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM