js如何获取键盘高度
在移动端或混合app开发中,js如何获取键盘高度,直接贴上代码吧
input是一个html input 标签
var timer = { id:null, run:function (callback,time) { this.id = window.setInterval(callback,time); }, clean:function () { var that = this; this.id = window.clearInterval(that.id); } }; var keyboardHeight = 0,screenHeight = window.innerHeight; input.addEventListener('focus',function (evt) { if(!keyboardHeight){ timer.run(function () { if (screenHeight !== window.innerHeight) { keyboardHeight = screenHeight-window.innerHeight; timer.clean() } }, 50) } }); input.focus();

浙公网安备 33010602011771号