解决方案:当软键盘弹出时,防止页面滚动,点击其他区域关闭软键盘
代码如下:
var closeKeyboard = function (e) {
if (e.target != document.activeElement) {
document.activeElement.blur();
}
};
document.addEventListener("focusin", function () {
document.addEventListener("touchend", closeKeyboard);
});
document.addEventListener("focusout", function () {
document.removeEventListener("touchend", closeKeyboard);
});