为什么notnt window.location.href =没有使用Safari转发到页面?

Dan*_*007 4 javascript facebook-javascript-sdk parse-platform

我的网站允许用户通过Fb按钮登录,我正在使用FB/Parse.com JDK进行此https://parse.com/docs/js/guide#users-facebook-users

一旦识别出用户,下面的代码就会记录用户并将其转发到网址上.这在Chrome下可以正常使用,但无法使用Safari,该页面只保留在空白的fb.html页面上

我已经看到有一些历史问题

window.location.href =

但是,找不到适用于我的解决方案的修复程序.有没有人知道这方面的方法?

Parse.FacebookUtils.logIn(null, {
    success: function(user) {
        if (!user.existed()) {

        } else {
            window.location.href="user_home.html";

        }
    },
    error: function(user, error) {

    }
});
Run Code Online (Sandbox Code Playgroud)

std*_*b-- 10

所有浏览器的最佳方式:

setTimeout(function(){document.location.href = "user_home.html";},250);
Run Code Online (Sandbox Code Playgroud)


Mer*_*erb 6

我在 safari 上也遇到过这种情况,并找到了这篇文章,但找到了另一个我想添加大量浏览器支持的解决方案。使用位置对象上名为 allocate() 的方法代替替换当前位置

document.location.assign(document.location.origin + "/user_home.html")
Run Code Online (Sandbox Code Playgroud)

这也有效

location.assign(location.origin + "/user_home.html")
Run Code Online (Sandbox Code Playgroud)

在桌面和移动 iOS 设备上的 Chrome 和 safari 中进行了测试

参考:https: //www.w3schools.com/jsref/met_loc_assign.asp