Location.hash仅在Safari 7中为空

Cha*_*ton 5 javascript safari postmessage constantcontact oauth-2.0

我试图通过OAuth2在弹出窗口中使用Constant Contact进行身份验证.我$.postMessage用来在窗口之间发送数据,并且在大多数情况下,它工作得很漂亮.

我的问题是Safari.普通请求的URL如下所示:

https://example.com/oauth-v2/#access_token=xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx&token_type=Bearer&expires_in=xxxxxxxxx

但是,当使用Safari发出请求,整个哈希被切断的URL和location.hash,window.location.hash,window.parent.location.hash都是空的.

身份验证流程相当标准:

  1. 用户单击auth按钮
  2. 使用常量联系人进行身份验证的弹出窗口
  3. 允许申请
  4. 项目清单
  5. 返回应用网站以捕获令牌

这是我们用来获取URL哈希信息的javascript

jQuery(document).ready(function ($) {
  $.extend({
    getQueryParameters: function (str) {
      return (str || document.location.search || document.location.hash)
        .replace(/(^\?)|(^\#)/, '')
        .split("&")
        .map(function (n) { return n = n.split("="), this[n[0]] = n[1], this }.bind({}))[0];
    }
  });
  $.receiveMessage(function (event) {
    $.postMessage($.getQueryParameters(), event.origin, event.source);
    setTimeout(function () {
      window.close()
    }, 5000);
  });
});
Run Code Online (Sandbox Code Playgroud)

丢失的哈希值是Safari中的已知错误吗?我应该做些什么来从Constant Contact获取信息吗?它适用于所有其他浏览器,所以我不想重写这部分应用程序.