783访问人次
Camila Waz 2022-01-22 18:22:10
39
2023-06-17 10:19:32 39阅读 0喜欢
<body onhashchange="myFn()">
    <a href="#123">123</a>
    <a href="#456">456</a>
</body>
<script>
    function myFn() {
        console.log('good1230.com')
    }
</script>
31
2023-06-17 09:53:41 31阅读 0喜欢
let textarea = document.querySelector('textarea')
    textarea.onbeforeinput = function (e) {
        let RegEx = /[0-9]/
        if (RegEx.test(e.data)) {
            e.returnValue = false
        }
    }
483
2022-10-03 12:12:10 483阅读 0喜欢

https://zh.javascript.info/fetch

async test() {
  let response = await fetch('good4/test/1.jpg');

  let blob = await response.blob(); // 下载为 Blob 对象
  const progressBar_max = document.getElementById("progressBar_max");

  progressBar_max.innerHTML = `${(blob.size / 1024 / 1024).toFixed(3)}MB`;

  // 为其创建一个 <img>
  let img = document.createElement('img');
  img.style = 'width:100px';
  document.body.append(img);

  // 显示它
  img.src = URL.createObjectURL(blob);
},
26
2022-10-02 11:10:49 26阅读 0喜欢

https://zinoui.com/blog/ajax-request-progress-bar

download() {
    var progressBar = document.getElementById("progress");
    var progressBar_value = document.getElementById("progressBar_value");
    var progressBar_max = document.getElementById("progressBar_max");

    var xhr = new XMLHttpRequest();
    xhr.open("GET", "/good4/1.jpg?" + Math.floor(Math.random() * 99999), true);
    xhr.responseType = "text";
    xhr.onprogress = function (e) {
        console.log(e)
        if (e.lengthComputable) {
        progressBar.max = e.total;
        progressBar.value = e.loaded;
        progressBar_value.innerHTML = `${(e.loaded / 1024 / 1024).toFixed(3)}MB`;
        progressBar_max.innerHTML = `${(e.total / 1024 / 1024).toFixed(3)}MB`;
        }
    };
    xhr.onloadstart = function (e) {
        progressBar.value = 0;
    };
    xhr.onloadend = function (e) {
        progressBar.value = e.loaded;
    };
    xhr.send(null);
}
2022-10-01 16:25:55 31阅读 0喜欢