<input type="text" value="" class="tinput" />;
//针对直接在浏览器打开此方法有效
$(".tinput").bind("focus", function () {
// 软键盘弹起之后再调整滚动条位置
if ($(this).offset().top > document.body.scrollHeight / 2) {
setTimeout(function () {
window.scrollTo(0, document.body.scrollHeight);
}, 500);
}
});
//针对嵌入app页面用以下方法
$(".tinput").focus(function (e) {
var u = navigator.userAgent;
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
if (isAndroid) {
$("body").height($("body").height() + 300);
$("body").scrollTop(300);
}
});
// 失去焦点时重新回到原来的状态
$(".tinput").blur(function (e) {
var u = navigator.userAgent;
var isAndroid = u.indexOf("Android") > -1 || u.indexOf("Adr") > -1; //android终端
if (isAndroid) {
$("body").height($("body").height() - 300);
$("body").scrollTop(0);
}
});
// 苹果手机使用第三方输入法
$(".tinput").on("focus", function () {
var that = this;
setTimeout(function () {
that.scrollIntoView(true);
}, 100);
});
H5移动端底部input唤醒手机软键盘遮挡输入框问题解决办法
最新推荐文章于 2024-03-08 14:38:53 发布