为什么我的页面在重新加载时向下滚动了一点



由于某种原因,当我重新加载页面时,它会向下滚动一小段。原因是这个代码,但我不知道为什么。

<script>
window.scrollBy({
top: 100,
left: 0,
behavior: 'smooth'
});
</script>

这会迫使一个小卷轴吗?我以为这只是链接的帮助。

这是来自mdn文档https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy

The Window.scrollBy() method scrolls the document in the window by the given amount.

因此,是的,最高值将使您的窗口滚动100px

最新更新