12

I'm having issue redirecting a webpage on all browsers. I created a custom page for a client about a year back on SHOPIFY and now the redirect function no longer works.

I was originally using document.location.href = "/cart" and all worked well. But I recieved a call from him today saying the page wont redirect anymore on his IPhone.

I changed it to window.top.location.href, this fixed it for most browsers except safari. I understand that the best way for this to work on all browsers is the document version. But that seems to have been out dated this year.

    setTimeout(function(){ document.location.href = '/cart';},1000);

Checking the user agent of the browser and if it's safari we can do a different tailored version of a redirect, just haven't found out how to do this on the new safari yet.

@stanislav seems to have the same issue from this link, I suspect we will start to see the number of people with this issue growing.

Why isnt window.location.href= not forwarding to page using Safari?

Thanks to all for the input and suggestions, hoping to get the resolved soon.

Brandon Nadeau
  • 3,568
  • 13
  • 42
  • 65
  • Do you have access to the server? Consider using [URL Redirection](https://en.wikipedia.org/wiki/URL_redirection). – BlueWater86 Jan 16 '20 at 21:51
  • Sorry will update the post. It's a `shopify` website so I do not. – Brandon Nadeau Jan 16 '20 at 21:53
  • Does this answer your question? [How do I redirect to another webpage?](https://stackoverflow.com/questions/503093/how-do-i-redirect-to-another-webpage) – BlueWater86 Jan 16 '20 at 22:24
  • 2
    No. I've tried almost all the combinations possible of `window.location`, `window.top.location`, `duciment.location`, all of the `assign()`, `replace()` combinations. – Brandon Nadeau Jan 16 '20 at 22:29
  • It seems I'm not the only one that has this issue now. Safari must of had an update recently. @stanislav is saying the same here https://stackoverflow.com/questions/31223216/why-isnt-window-location-href-not-forwarding-to-page-using-safari – Brandon Nadeau Jan 18 '20 at 17:00
  • I feel like Safari is the new IE - going rogue with the way it behaves, especially with unannounced behavior changes like this. I'm also aware that it stops running animations, even animated GIFs, at page unload. – JD Smith Feb 27 '20 at 18:11
  • Please add full path url first then test – A.A Noman Mar 25 '21 at 13:04

1 Answers1

0

try upgrade , Safari version 14 fixed this bug.

Rawand Deheliah
  • 1,220
  • 10
  • 11