0

Certain constraints are requiring me to use strictly out of the box JavaScript.

window.setTimeout(function() {
  window.location = "https://www.google.com/";
}, 10000);

So the redirect works but it fires the redirect after approx 3000 ms instead of 10000 ms. No matter how long I set the wait time for it always fires the redirect after 3000 ms. This works perfectly in regular web browsers and in mobile chrome. Just not in mobile safari.

Any thoughts?

P.S. I'm not actually trying to redirect to google. I'm just not using the production url.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
  • May be not setTimeout but window.location makes the trouble https://stackoverflow.com/questions/16714578/use-of-window-location-doesnt-work-on-ipad – Thomas Jul 30 '20 at 18:19
  • what is the reason for using "window.setTimeout" instead of just "setTimeout"? – Rick Jul 30 '20 at 18:27
  • Try using just setTimeout and also use window.location.href instead. – Saiansh Singh Jul 30 '20 at 18:32
  • I tried using window.location.href and I also tried using just setTimeout. Same results. The redirect fires either way it just fires after approx. 3ms no matter how much time I add. – Austin Mudd Jul 31 '20 at 16:23
  • @AustinMudd If you run JavaScript from **.js** file, don't forget to add new random query string value on every save changed to force browser download new version. Example **myfile.js?v=20221016114048**. – vee Oct 16 '22 at 04:40

0 Answers0