我有一个奇怪的问题,我只能在Microsoft浏览器上复制(已测试Edge和IE11)。
<style>
body {
height: 5000px;
width: 5000px;
}
</style>
<p>Click the button to scroll the document window to 1000 pixels.</p>
<button onclick="scrollWin()">Click me to scroll!</button>
<script>
function scrollWin() {
window.scrollTo({
left: 1000,
top: 1000,
behavior:"smooth"
});
}
</script>Run Code Online (Sandbox Code Playgroud)
这段代码可以正确地将窗口向左和向下滚动1000px,在Chrome和Firefox中行为流畅。但是,在Edge和IE上,它根本不会移动。