Emil Johnsson
Emil Johnsson

Reputation: 2976

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>

Upvotes: 1

Views: 2910

Answers (2)

DaNnY BoY
DaNnY BoY

Reputation: 21

@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?

Upvotes: 0

pkh80
pkh80

Reputation: 11

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.

Upvotes: 1

Related Questions