【问题标题】:Safari browser crashes on redirect window.locationSafari 浏览器在重定向 window.location 时崩溃
【发布时间】:2018-05-09 11:11:24
【问题描述】:

我正在使用此代码打开应用程序,如果它已安装,否则将要求安装。

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

【问题讨论】:

    标签: javascript ios mobile-safari


    【解决方案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
    

    【讨论】:

      【解决方案2】:

      使用window.location.href

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

      【讨论】:

      • 我使用了你的代码,但那个代码也会导致崩溃。
      • 但是,在我的 safari 5.1.7 (windows) 上工作的代码。控制台中显示任何错误?
      • 问题出在 iPhone Safari 浏览器上。
      • 试试这个document.location.replace("https://google.com"); 但无法返回页面。
      • document.location.replace 也崩溃了。
      猜你喜欢
      • 2014-07-26
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 1970-01-01
      • 2018-03-21
      • 1970-01-01
      • 2023-01-25
      • 1970-01-01
      相关资源
      最近更新 更多