短评 · ·

X 归档 2018-08-29

1 条动态 · 图 0 · 视频 1
Someone asked how you can change the `document.title` of your page to your current heading. ⌨️ Whipped up a solution using IntersectionObserver. Could be improved, but a decent start ~14SLOCs 🙃

Demo: https://reddit-stuff.glitch.me/9b09jx.html
Code: https://glitch.com/edit/#!/reddit-stuff?path=9b09jx.html
有人问怎么把页面的 `document.title` 改成当前标题。⌨️ 用 IntersectionObserver 迅速搓了个方案。还有改进空间,但作为起点还不错,约 14 行代码 🙃

演示:https://reddit-stuff.glitch.me/9b09jx.html
代码:https://glitch.com/edit/#!/reddit-stuff?path=9b09jx.html