Safari浏览器在重定向window.location时崩溃

时间:2018-05-09 11:11:25

标签: javascript ios mobile-safari

我正在使用此代码打开应用程序,如果其安装的其他人将要求安装。

window.setTimeout(function () {
        var end = (new Date()).valueOf();
        if (end - start < 1000) { 
            window.setTimeout(function () {
                window.location = pageurl;//will be redirected to webpage crash is happening here
            }, 5);
            window.location = storeurl;
        } else {
            window.location = pageurl;
        }
    }, 5);
    window.location = appicationurl;// will defaultly open application

2 个答案:

答案 0 :(得分:1)

尝试window.open(pageurl);

 window.setTimeout(function () {
            var end = (new Date()).valueOf();
            if (end - start < 1000) { 
                window.setTimeout(function () {
                    window.open(pageurl);//will be redirected to webpage crash is happening here
                }, 5);
                window.location = storeurl;
            } else {
                window.location = pageurl;
            }
        }, 5);
        window.location = appicationurl;// will defaultly open application

答案 1 :(得分:0)

使用window.location.href

window.setTimeout(function () { 
                         window.location.href = "http://sample.com"; 
                    }, 5000);