<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)
}
})