After calling history.pushState in Safari on iOS, you can no longer use alert() , confirm() or prompt() when using the back button in a browser.
Is this an iOS bug? Are there any known workarounds?
A simple example to reproduce this behavior:
<html> <body> <ul> <li>Step 1: <button onclick="alert(Math.random())">Confirm Alert is working</button></li> <li>Step 2: <button onclick="history.pushState(null, null, '/debug/'+Math.random());">Change History</button></li> <li>Step 3: use your browser back button, to go back</li> <li>Step 4: <button onclick="alert(Math.random())">Alert is not working anymore</button></li> </ul> </body> </html>
You can try it online here: goo.gl/faFW6o .
source share