0

I've got a non-responsive page I need to include via iframe. In order to show the entire iframe I dynamically set the viewport width and scale using javascript. When I'm ready to close the iframe I reset the viewport width and scale to the original values.

Normally this works fine. However, if the on-screen keyboard is opened (e.g. on text input focus) iOS refuses to honor any further scaling. It will honor the viewport resize, just not the initial-scale. Interestingly, if you rotate the device it will eventually honor the initial-scale.

I think this may just be an iOS bug. Any advice would be greatly appreciated.

4

1 回答 1

0

所以看起来诀窍只是再次触发键盘。键盘打开后,您设置的视口比例将立即生效。

让键盘弹出说起来容易做起来难。基本上,您必须处理真正的单击事件或 mouseup 事件,然后直接从单击处理程序(http://jsfiddle.net/DLV2F/87/)触发文本输入焦点。

<input>
<p id="click">Click handler</p>
<p id="click-timeout">Click handler setting timeout</p>
<p id="mousedown">Mousedown handler</p>
<p id="mousedown-timeout">Mousedown handler setting timeout</p>
<p id="mouseup">Mouseup handler</p>
<p id="mouseup-timeout">Mouseup handler setting timeout</p>
<p id="extern-click-trigger">Clicking here will trigger click on the first 'Click Handler'</p>
<p id="tap">Virtual 'TAP' handler</p>
<p id="tap-triggering-click">Virtual 'TAP' handler triggering click on the first 'Click handler'</p>

<script>
function focus() {
    $('input').focus();
}
$(focus);
$(function() {
    $(document.body).load(focus);
    $('#click').click(focus);
    $('#click-timeout').click(function() {
        setTimeout(focus);
    });
    $('#mousedown').mousedown(focus);
    $('#mousedown-timeout').mousedown(function() {
        setTimeout(focus);
    });
    $('#mouseup').mouseup(focus);
    $('#mouseup-timeout').mouseup(function() {
        setTimeout(focus);
    });
    $('#extern-click-trigger').click(function() {
        $('#click').click();
    });
    $('#tap').bind('tapone', function() {
        focus();
    });
    $('#tap-triggering-click').bind('tapone', function() {
        $('#click').click();
    });

});
</script
于 2013-08-06T21:50:46.097 回答