PageSourceSearch

https://www.3people.com.tw/activity/news1/%E5%9C%8B%E8%80%83%E8%BD…1%B7%E8%B6%85%E4%BA%BA/scripts/backToTop.js

js 3people.com.tw collected 2026-10-02 03:27:24 UTC 747 bytes, 27 lines download raw bytes

1/**
2 * 回到頂部函式
3 * 支援原生平滑捲動
4 */
5function scrollToTop() {
6    window.scrollTo({
7        top: 0,
8        behavior: 'smooth' // 平滑捲動效果
9    });
10}
11
12/**
13 * 進階優化:捲動一定距離後才顯示按鈕
14 * 監聽視窗捲動事件
15 */
16window.onscroll = function() {
17    var btn = document.getElementById("backToTopBtn");
18    // 當捲動超過 300px 時顯示按鈕,否則隱藏
19    if (document.body.scrollTop > 300 || document.documentElement.scrollTop > 300) {
20        btn.style.opacity = "1";
21        btn.style.display = "block";
22    } else {
23        btn.style.opacity = "0";
24        // 如果你希望完全消失不佔空間,可以取消註解下一行
25        // btn.style.display = "none";
26    }
27};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.