简体   繁体   中英

how to check that how much page has been loaded

I am trying to make a progress bar through java script library progress.js and i want to show that how much page has been. I want to do this through my progress bar. How can i check that how much page has been loaded?

May be your need to try by calculating response header size and then calculate %

var request = new XMLHttpRequest();
request.open('GET', document.location, false);
request.send();
var size = request.getAllResponseHeaders().toLowerCase().match(/content-length: \d+/);
alert(size);

You will get size in bytes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM