Javascript File Download Monitoring Help?

/*
I am testing this fragment of html5 and javascript on Firefox 64 bit 90.02 on 64 bit Windows 10. There is no web server software serving this page, and it is just a local file being opened by the test web browser. This code has no syntax errors so far, its just that the request.onprogress does not catch every fetch iteration of the file download, when triggered after being given a save destination, via the mouse on the href tag in the web browser. This code doesn’t catch each iteration of the file download, and populate event.loaded and event.total each time, with a bytes number, to ultimately all be used to update the progress bar. Can someone get this code to behave as I wish so far, so that I can continue with the rest, plase? Or otherwise explain why this code fragment doesn’t
behave as expected?
*/

var fileName = document.getElementsByName(“download1”)[0]
.getAttribute(“href”).toString();

var request = new XMLHttpRequest();

request.responseType = “blob”;

request.onprogress = function(event)
{
//alert(“request.onprogress has fired.”);

if(event.lengthComputable)
{
alert("Progress so far: " + event.loaded + ". Total file size: " +

event.total + “.”);
}
};

request.open(“GET”, fileName, true);

request.send();

/*
The following turns off the local file, non-webbrowser, firefox XMLHttpRequest error.

about:config security.fileuri.strict_origin_policy true stops, false allows through.
*/

document.getElementsByName(“progress1”)[0].value = 0;
//number as a percentage, 0-100.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.