在history.pushStateiOS上调用Safari 后,当使用浏览器后退按钮进行更改时,不再可以使用alert(),confirm()或prompt().
这是iOS错误吗?有没有已知的解决方法?
重现此行为的简单示例:
<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>
Run Code Online (Sandbox Code Playgroud)
你可以在这里尝试一下:goo.gl/faFW6o.