Facebook like button redirect? [closed]

你。 提交于 2019-12-08 05:26:59

问题


Is it possible to add a like button feature to your Facebook page which re-directs to another page and offers the user a free ebook?

I'm creating a website within MODx which runs via PHP.


回答1:


For only like button:

<div id="fb-root"></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_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


<div id="fblike">
  <div class="fb-like" data-href="site name" data-send="false" data-layout="button_count" data-width="100" data-show-faces="false"></div>
</div>

Redirect after clicking Like button:

This can be handled with the Facebook javascript event, edge.create:

FB.Event.subscribe('edge.create',
    function(response) {
        location.href = 'http://yourdomain.com/post/id';
    }
);

may this help you.



来源:https://stackoverflow.com/questions/15427045/facebook-like-button-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!