javascript - 为什么我的页面在重新加载时会向下滚动一点
问题描述
出于某种原因,当我重新加载页面时,它会向下滚动一点。原因是这段代码,但我不知道为什么。
<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
推荐阅读
- python - 如何检索相应名称的值以在方程式中将其计算为python中df中的新列
- ms-access - 您请求的更改不成功(错误 3022)
- kubernetes - 使用 Azure DevOps Pipeline 部署时收到 VS 2019 Container Application for Kubernetes 错误
- r - 按一列的最大值汇总数据框
- java - 如何替换 ArrayList 的特定部分?
- php - 通过表单的 SQL 注入在 PHP 5.6 中不起作用
- oracle - 如何以 root 用户身份登录 Oracle 的 rman
- php - php将文件保存到相对路径
- amazon-web-services - 在 dynamodb 中存储具有超过 15 个属性的对象时,最好将其作为对象存储在 value 中还是将它们分布在列中?
- php - PHP 检查一个变量是否等于其他三个变量之一