简体   繁体   中英

JavaScript confirm() on Safari iOS7

EDIT: This has been resolved in iOS7 update 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. 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 . Is a custom implementation that mimics confirm()-functionality still the only viable workaround?

<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

I can occasionally get Safari to work correctly by closing it an re-opening, but most of the time it does not work.

@pkh80 I found Alertify.js which helped me resolve my issues regarding prompts, alerts, confirms, etc in 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?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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