diff --git a/_scripts/scrollTo.js b/_scripts/scrollTo.js new file mode 100644 index 0000000000000000000000000000000000000000..d8710f3fd5a9f6a54180361ab836be0974f9d483 --- /dev/null +++ b/_scripts/scrollTo.js @@ -0,0 +1,29 @@ +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') + { + if(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.pageYOffset) < window.document.getElementById(decodeURI(surlp[1])).offsetTop) + + } + } + } + } + } +} diff --git a/index.html b/index.html index 50b916251814e0e14b910f26f5d911ed841fb3a0..52cd7d0541c65b91f62fa932bac2feb598da6dfc 100644 --- a/index.html +++ b/index.html @@ -86,7 +86,7 @@ editHtml + html + '\n\n----\n' + - '>我有疑问: [RT-Thread 官方论坛](https://club.rt-thread.org/)' + '>我有疑问: [RT-Thread 官方论坛](https://club.rt-thread.org/)'+'