1 Star 0 Fork 0

RTduino/docs

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
scrollTo.js 1.81 KB
一键复制 编辑 原始数据 按行查看 历史
满鉴霆 提交于 2024-01-22 02:01 +08:00 . upload document page
if(location.hash.indexOf('?')>-1)
{
var urlp = location.hash.split('?');
if(urlp.length>0)
{
var up = urlp[1].split('&');
for(var u in up)
{
var surlp = up[u].split('=');
for(var s in surlp)
{
if(surlp[0] === 'id')
{
// console.log(parseInt(window.pageYOffset), window.document.getElementById(decodeURI(surlp[1])).offsetTop)
// console.log(parseInt(window.document.body.scrollHeight)-parseInt(window.document.body.clientHeight))
if(parseInt(window.pageYOffset)!==0 && parseInt(window.pageYOffset) < window.document.getElementById(decodeURI(surlp[1])).offsetTop)
{
var setT = setTimeout(function(){
location.reload();
if(parseInt(window.pageYOffset) >= window.document.getElementById(decodeURI(surlp[1])).offsetTop)
clearTimeout(setT);
},500);
// console.log(parseInt(window.pageYOffset) < window.document.getElementById(decodeURI(surlp[1])).offsetTop)
console.log(parseInt(window.document.body.scrollHeight)-parseInt(window.document.body.clientHeight),parseInt(window.document.getElementById(decodeURI(surlp[1])).offsetTop))
//页面全高-屏幕高度如果大于滚动栏高度,则清除滚动
if(parseInt(window.document.body.scrollHeight)-parseInt(window.document.body.clientHeight)<parseInt(window.document.getElementById(decodeURI(surlp[1])).offsetTop))
{
clearTimeout(setT);
}
}
}
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/rtduino/docs.git
git@gitee.com:rtduino/docs.git
rtduino
docs
docs
master

搜索帮助