一旦用户完成推文,我该如何关闭Twitter web意图?

时间:2015-05-27 07:13:48

标签: javascript twitter

我使用以下脚本启用tweet /转推/收藏的推文帖子。我需要在动作完成后自动关闭弹出窗口。

我已经使用了Twitter web意图代码,但即使在操作完成后也没有关闭弹出窗口。有没有办法做同样的事?

<script type="text/javascript">
        window.twttr = (function(d, s, id) {
          var js, fjs = d.getElementsByTagName(s)[0],
            t = window.twttr || {};
          if (d.getElementById(id)) return;
          js = d.createElement(s);
          js.id = id;
          js.src = "https://platform.twitter.com/widgets.js";
          fjs.parentNode.insertBefore(js, fjs);
         
          t._e = [];
          t.ready = function(f) {
            t._e.push(f);
          };
         
          return t;
        }(document, "script", "twitter-wjs"));
         
        // Define our custom event handlers
        function tweetIntentToAnalytics (intentEvent) {
        	  if (!intentEvent) return;
        	  window.close();
        	  window.location.reload();
        }
         
        function favIntentToAnalytics (intentEvent) {
        	if (!intentEvent) return;
        	window.close();
        	window.location.reload();
        }
         
        function retweetIntentToAnalytics (intentEvent) {
          if (!intentEvent) return;
          window.close();
        	window.location.reload();
        }
        
        // Wait for the asynchronous resources to load
        twttr.ready(function (twttr) {
          // Now bind our custom intent events
           twttr.events.bind('tweet', tweetIntentToAnalytics);
          twttr.events.bind('retweet', retweetIntentToAnalytics);
          twttr.events.bind('favorite', favIntentToAnalytics);
          });
</script>
<div class="action_bot">
    	<a href="https://twitter.com/intent/tweet?in_reply_to=<?php echo $res['id'];?>"><span class="reply"></span></a>
    	<a href="https://twitter.com/intent/retweet?tweet_id=<?php echo $res['id'];?>"><span class="retweet"><?php echo $res['re_count']; ?></span></a>
        <a href="https://twitter.com/intent/favorite?tweet_id=<?php echo $res['id'];?>"> <span class="favorite"><?php echo $res['fb_count'];?></span></a>
    </div>
    
    

0 个答案:

没有答案