Why isnt [removed].href= not forwarding to page using Safari?

后端 未结 4 1769
情话喂你
情话喂你 2020-12-03 22:41

My site lets users login via the Fb button, I\'m using the FB / Parse.com JDK for this https://parse.com/docs/js/guide#users-facebook-users

Once the user has been id

相关标签:
4条回答
  • 2020-12-03 23:21

    When I stack to this problem, I made function what working well on any Safari and also all browsers including mobile browsers:

    function windowLocation(url){
        var X = setTimeout(function(){
            window.location.replace(url);
            return true;
        },300);
    
        if( window.location = url ){
            clearTimeout(X);
            return true;
        } else {
            if( window.location.href = url ){
                clearTimeout(X);
                return true;
            }else{
                clearTimeout(X);
                window.location.replace(url);
                return true;
            }
        }
        return false;
    };
    

    Is a bit "dirty" solution but give you ability to redirect your page in any case.

    0 讨论(0)
  • 2020-12-03 23:24

    Best way work in all browsers:

    setTimeout(function(){document.location.href = "user_home.html";},250);
    
    0 讨论(0)
  • 2020-12-03 23:39

    I had this happening to me as well on safari and found this post but found another solution I wanted to add with lots of browser support. Instead of replacing the current location use the method that is on the location object called assign()

    document.location.assign(document.location.origin + "/user_home.html")
    

    This also works

    location.assign(location.origin + "/user_home.html")
    

    Tested in Chrome and safari on desktop and mobile iOS devices

    reference: https://www.w3schools.com/jsref/met_loc_assign.asp

    0 讨论(0)
  • 2020-12-03 23:40

    I think you need to use...

    window.location = 'user_home.html';
    
    0 讨论(0)
提交回复
热议问题