Add hashEvent
This commit is contained in:
parent
94436b5395
commit
59ab4bfea7
2 changed files with 29 additions and 0 deletions
|
|
@ -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>
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
28
test_data/src/scripts/hashEvent.js
Normal file
28
test_data/src/scripts/hashEvent.js
Normal 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)
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue