Close facebook share popup after share is complete?

为君一笑 提交于 2019-12-23 19:00:31

问题


I'm attempting to share a link on facebook via url. I get the share to work, however instead of loading the redirectURI, I want to close the popup window. My code:

function fb_share(url) { window.open(url,"share_window","width=400,height=300"); }
...
fb_share('http://www.facebook.com/dialog/feed?app_id=128000000000&link=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%128000000000%26sk%128000000000&picture=http://www.google.com/images/nav_logo83.png&name=name&description=description&redirect_uri=http%3a%2f%2fwww.facebook.com%2fapps%2fapplication.php%3fid%3d128398017257108%26sk%3dapp_128000000000&display=popup')

回答1:


I wrote a page that can be used as the redirect_uri, which will close popup via javascript: http://www2.highpoint.edu/close_popup.php

View the source to see some simple HTML:

<!doctype html>
<html>
  <h3>Thank you!</h3>
  <a href="javascript:close();">Close this window</a>
  <script type="text/javascript">
    close();
  </script>
</html>

It works when used as the callback from a Facebook Dialog.




回答2:


Redirected url contains parameter post_id, so you can check on it and close window if you find it:

if (window.location.search.indexOf('post_id') == 1){
  window.close();
}


来源:https://stackoverflow.com/questions/7197000/close-facebook-share-popup-after-share-is-complete

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