本文主要介紹了HTML5 虛擬鍵盤出現(xiàn)擋住輸入框的解決辦法。具有很好的參考價值,下面跟著小編一起來看下吧
話不多說,請看代碼:
//防止鍵盤把當(dāng)前輸入框給擋住 $$('input[type="text"],textarea').on('click', function () { var target = this; setTimeout(function(){ target.scrollIntoViewIfNeeded(); },100); });
部分安卓機型適用。
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); } }) }
【相關(guān)推薦】
1. Html5免費視頻教程
2. 關(guān)于H5新標(biāo)簽的瀏覽器兼容問題的詳解
3. 教你如何用H5無刷新改變當(dāng)前url的實例詳解
4. 通過phonegap操作數(shù)據(jù)庫的的教程詳解
5. H5中indexedDB 數(shù)據(jù)庫的使用方法詳解