Add hashEvent

This commit is contained in:
Hyunchul Kim 2020-11-23 03:31:46 +09:00
parent 94436b5395
commit 59ab4bfea7
2 changed files with 29 additions and 0 deletions

View file

@ -68,6 +68,7 @@ html_footer = """
</div> </div>
<script src="/src/scripts/updateIntroduction.js"></script> <script src="/src/scripts/updateIntroduction.js"></script>
<script src="/src/scripts/updateArchive.js"></script> <script src="/src/scripts/updateArchive.js"></script>
<script src="/src/scripts/hashEvent.js"></script>
</body> </body>
</html> </html>
""" """

View file

@ -0,0 +1,28 @@
let target = window.location.hash.slice(1);
console.log(target)
console.log("~~~")
try {
document.getElementById(target).classList.add("focus");
window.scrollTo(window.screenTop-100,0)
setTimeout(()=>{
document.getElementById(target).classList.remove("focus")
}, 1000)
}catch(e){
}
try {
document.querySelector('.octet-stream').remove();
}catch(e){
}
window.addEventListener("hashchange", ()=>{
let target = window.location.hash.slice(1);
console.log(target)
document.getElementById(target).classList.add("focus");
setTimeout(()=>{
document.getElementById(target).classList.remove("focus")
}, 1000)
// window.screenTop = window.screenTop-300;
// window.scrollTo(window.screenTop-100,0)
});