从iframe发布到墙后重定向

时间:2012-01-04 16:44:36

标签: javascript facebook facebook-javascript-sdk fb.ui

我想知道在使用发布到墙上弹出对话框之后,可以将某人重定向到另一个标签页。

当前发布到墙脚本。

<script type="text/javascript">
window.fbAsyncInit = function() {
  FB.init({appId: APPID,
              status: true,
              cookie: true,  
              xfbml: true});  };  
     (function() {
         var e = document.createElement('script');
         e.async = true;  
         e.src = document.location.protocol +  
         '//connect.facebook.net/en_US/all.js';
         document.getElementById('fb-root').appendChild(e);
     }());
 </script>

<script>
function publish_to_wall(){
   FB.ui({ 
     method: 'stream.publish',
     display: 'iframe',
     name: ('some text ') + (document.getElementById('myText').value) +(' some text'),
     caption: 'some caption',
     link: 'some url',
     picture:'some image url'
   });
 }
</script>

重定向必须在iframe内发生。所以当有人将帖子发布到他/她的墙上之后,人们会被重新调整到一个谢谢你的页面。

1 个答案:

答案 0 :(得分:2)

这样的东西?

feedData = {};
feedData.method = 'feed';
feedData.name = "title";
feedData.link = "url";
feedData.picture = "url to picture";

FB.ui(feedData,function(feedResponse) {
    if (response && response.post_id) {
        alert('Post was published.');
        //do redirect
window.location = "url to thank you page"
    } else {
        alert('Post was not published.');
    }

});