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

前端 未结 7 1133
感动是毒
感动是毒 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:18

    I think that a bug related to the smooth hiding selection boxes animation. I do not like hacks, but this method works. Confirming called after 100 ms (this is enough for the time until the selection window closes)

    var object;
    
    $('form select').change(function()
    {
        object = $(this);
        timer = setTimeout(confirmation, 100);
    });
    
    function confirmation()
    {
        switch(object.val())
        {
            case 'post_approved':
            case 'post_delete':
            case 'thread_delete': object.parent('form').find('input[name=id]').val(object.parent('form').find('input[name=post_id]').val()); break;
            case 'user_delete_all': object.parent('form').find('input[name=id]').val(object.parent('form').find('input[name=user_id]').val()); break;
            default: return false; break;
        }
    
        if(object.parent('form').find('input[name=act]').val() === 'post_approved'  || (object.parent('form').find('input[name=act]').val() != '' && confirm('Вы уверены?')))
            object.parent('form').submit();
        else
            return false;
    }
    

提交回复
热议问题