var focusElem; //获取页面高度 var clientHeight = document.body.clientHeight; //设置监听聚焦事件 document.body.addEventListener("focus", function(e) { focusElem = document.getElementById('content') }, true); //设置监听窗口变化时间 window.addEventListener("resize", function() { if(focusElem && document.body.clientHeight < clientHeight) { //使用scrollIntoView方法来控制输入框 focusElem.scrollIntoView(false); } });