PageSourceSearch

https://www.bjhdedu.cn/jw_js/rem.js

js bjhdedu.cn collected 2026-10-07 20:27:20 UTC 1,497 bytes, 46 lines download raw bytes

1(function (designWidth, maxWidth) {
2    var doc = document,
3        win = window,
4        docEl = doc.documentElement,
5        remStyle = document.createElement("style"),
6        tid;
7
8    function refreshRem() {
9        var width = docEl.getBoundingClientRect().width;
10        maxWidth = maxWidth || 540;
11        width > maxWidth && (width = maxWidth);
12        var rem = width * 100 / designWidth;
13        remStyle.innerHTML = 'html{font-size:' + rem + 'px;}';
14    }
15
16    if (docEl.firstElementChild) {
17        docEl.firstElementChild.appendChild(remStyle);
18    } else {
19        var wrap = doc.createElement("div");
20        wrap.appendChild(remStyle);
21        doc.write(wrap.innerHTML);
22        wrap = null;
23    }
24    //要等 wiewport 设置好后才能执行 refreshRem,不然 refreshRem 会执行2次;
25    refreshRem();
26
27    win.addEventListener("resize", function () {
28        clearTimeout(tid); //防止执行两次
29        tid = setTimeout(refreshRem, 300);
30    }, false);
31
32    win.addEventListener("pageshow", function (e) {
33        if (e.persisted) { // 浏览器后退的时候重新计算
34            clearTimeout(tid);
35            tid = setTimeout(refreshRem, 300);
36        }
37    }, false);
38
39    if (doc.readyState === "complete") {
40        doc.body.style.fontSize = "16px";
41    } else {
42        doc.addEventListener("DOMContentLoaded", function (e) {
43            doc.body.style.fontSize = "16px";
44        }, false);
45    }
46})(750, 750);

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.