h5 ios移动端,键盘收起以后页面不归位

$('input,textarea').on('blur',function(){
window.scroll(0,0);
});
$('select').on('change',function(){
window.scroll(0,0);
});
document.body.addEventListener('focusout', function () {
window.scrollTo(0, 0);
})
失去焦点后,重新让滚动条滚动到之前的位置

$("input").blur(function () {
setTimeout(function() {
var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
window.scrollTo(0, Math.max(scrollHeight - 1, 0));
}, 100);
});

 

失去焦点以后重新设置页面顶部位置

posted on 2018-12-12 14:23  JasonGoIT  阅读(3824)  评论(0编辑  收藏  举报

导航