Twitter Web Intent Callbacks在IE中不起作用

Tom*_*ssi 6 javascript twitter

用户完成推文后,我一直试图让回调工作.除了Internet Explorer(11,10,9或8)之外,所有浏览器中的一切都很好用.IE在控制台中没有显示任何内容,回调也没有触发.

有人有解决方案吗?这是一个简单的例子来说明问题(jsfiddle):

<!DOCTYPE html>
<html lang="en">
<head>
 <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
</head>
<body>
 <a href="https://twitter.com/intent/tweet?&text=Test%20Message">Testing</a>

 <script>
  twttr.ready(function (twttr) {
    twttr.events.bind('tweet', function(event) {alert('twitter click');});
   });
 </script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

小智 0

这是由于在 IE 中的窗口之间发送数据时 postMessage 功能被破坏。IE 从 IE8 开始支持 iframe 的 postMessage,但不支持主窗口和弹出窗口之间的 postMessage,这与其他支持两者的主流浏览器不同。

参考:http://blogs.msdn.com/b/ieinternals/archive/2009/09/16/bugs-in-ie8-support-for-html5-postmessage-sessionstorage-and-localstorage.aspx