HTML5 虚拟键盘出现挡住输入框可以用代码
- 来源:纵横数据
- 作者:中横科技
- 时间:2018/1/3 10:33:08
- 类别:新闻资讯
1 2 3 4 5 6 7 | //防止键盘把当前输入框给挡住 $$( 'input[type="text"],textarea' ).on( 'click' , function () { var target = this ; setTimeout( function (){ target.scrollIntoViewIfNeeded(); },100); }); |
部分安卓机型适用。
1 2 3 4 5 6 7 8 9 | if (/Android [4-6]/.test(navigator.appVersion)) { window.addEventListener( "resize" , function () { if (document.activeElement.tagName== "INPUT" || document.activeElement.tagName== "TEXTAREA" ) { window.setTimeout( function () { document.activeElement.scrollIntoViewIfNeeded(); },0); } }) } |