“alert()” and “confirm()” not working with “apple-mobile-web-app-capable”

前端 未结 7 1141
感动是毒
感动是毒 2021-02-07 02:32

Under iOS (currently 7.0), it looks like alert() and confirm() are not working when our web app is pinned to the home screen (aka using the meta tag

7条回答
  •  余生分开走
    2021-02-07 03:10

    I don't know if it is by design or a bug but I can confirm this is a real problem. One other thing to be aware of is that if the user has the option to save passwords enabled, any site that requires a login will fail because that prompt is also blocked. (you can try this with a simple form with a username and password box and nothing else and it simply won't submit). There are workarounds though for all three issues.

    1. Login - set autocomplete="off" in the form tag for the site, or detect that the site is running IOS7 and in fullscreen mode and apply this setting

      $('form').attr('autocomplete', 'off');
      
    2. Alerts and Confirms - you can either write a custom function in JavaScript or override the existing functions in much the same way as here: http://andrewensley.com/2012/07/override-alert-with-jquery-ui-dialog/. I like using Eric Martin's SimpleModal plugin which has a built in Confirm override, the bottom demo on http://www.ericmmartin.com/projects/simplemodal-demos/.

    I hope some of that helps.

提交回复
热议问题