简体   繁体   English

Safari iOS7上的JavaScript Confirm()

[英]JavaScript confirm() on Safari iOS7

EDIT: This has been resolved in iOS7 update 7.0.2. 编辑:这已在iOS7更新7.0.2中解决。

I have seen issues with confirm() crashing Safari on iOS7 in web apps, but not seen anything regarding them in standard mode. 我已经看到在Web应用程序中iOS7上的validate confirm() Safari崩溃的问题,但是在标准模式下没有看到有关它们的任何信息。 The following code is from the W3schools example and Safari simply continues to execute past the confirm() and thus the variable r is always false . 以下代码来自W3schools示例,并且Safari继续继续执行verify()之后,因此变量r始终为false Is a custom implementation that mimics confirm()-functionality still the only viable workaround? 仍是唯一可行的解​​决方法,它是一种模仿confirm()功能的自定义实现?

<html>
    <head>
        <script>
        function disp_confirm() {
          var r = confirm('Press a button!');

          if (r == true) {
            alert('You pressed OK!');
          } else {
            alert('You pressed Cancel!');
          }
        }
        </script>
    </head>
    <body>
        <input type="button" onclick="disp_confirm()" value="Display a confirm box">
    </body>
</html>

This bug still exists for me for me in 7.0.2 and 7.0.3 对于我来说,此错误在7.0.2和7.0.3中仍然存在

I can occasionally get Safari to work correctly by closing it an re-opening, but most of the time it does not work. 我偶尔可以通过重新打开Safari使其正常工作,但大多数情况下它无法正常工作。

@pkh80 I found Alertify.js which helped me resolve my issues regarding prompts, alerts, confirms, etc in iOS7. @ pkh80我发现Alertify.js帮助我解决了有关iOS7中有关提示,警报,确认等的问题。 Here's the original post if it helps. 如果有帮助,这是原始文章。

Another user on that thread said he was able to get around issues by setting a timeout. 该线程上的另一个用户说,他可以通过设置超时来解决问题。 Maybe try the timeout as an easy start, then if necessary try to implement alertify and see if that solves it? 也许尝试将超时作为一个简单的开始,然后在必要时尝试实施alertify并查看是否可以解决该问题?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM