focus-preventScroll 2022-03-19 focus preventScroll 滚动 api123button.focus({ preventScroll: true }); 1234567<button id="button1">点击我获取焦点会定位</button><button id="button2">点击我获取焦点但不会定位</button><p class="remind">提示:浏览器可视区域的下面有两个输入框。</p><div style="margin-top: calc(100vh - 180px);"> <input id="input1" size="10"> <input id="input2" size="10"></div> 12345678button1.onclick = function () { input1.focus();};button2.onclick = function () { input2.focus({ preventScroll: true });}; demo猛戳查看 兼容情况 64+ ✔ 68+ ✔ ✘ ✘ 51+ ✔ ✘