'Redirection to external links fails on Safari

I am facing this strange issue only on safari. In my webapp app, I redirect to some links using window.location.href For all these links a connection lost error is returned from the browser on safari, working fine with chrome and firefox. And when I retry the link a few times, it also starts to work on Safari.

So for example there is a button A, which onClick has window.location.href to "https://example.net", now when I click any links of this type, on first attempts it fails on safari, never ever occurred on Chrome or Firefox. Also if the whole page is still loading and I click, it works. And everthing works in local enviroment, but doesn't work on stage and production. Please help me out on this one, I have tried a lot of combinations like using anchor links tags instead of button, but button was used for a reason. Anyways If anyone has similar issues and know something about, please help me.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source