Search code examples
javascriptiosmobile-safari

Safari browser crashes on redirect window.location


I am using this code to open application if its installed else will ask to install.

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

Solution

  • Try 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