This article mainly introduces the solution to the problem that the HTML5 virtual keyboard blocks the input box. It has a very good reference value. Let’s take a look at it with the editor. I hope it can help everyone.
Without further ado, please take a look at the code:
//防止键盘把当前输入框给挡住 $$('input[type="text"],textarea').on('click', function () { var target = this; setTimeout(function(){ target.scrollIntoViewIfNeeded(); },100); });
Applicable to some Android models.
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); } }) }
Related recommendations:
Virtual keyboard, the pain of mobile web development_html/css_WEB-ITnose
Create personalized functions Powerful Jquery virtual keyboard (VirtualKeyboard)_jquery
jquery implements page virtual keyboard effects_jquery
The above is the detailed content of What should I do if the HTML5 virtual keyboard appears and blocks the input box?. For more information, please follow other related articles on the PHP Chinese website!