you want to monitor the progress of the download when simulating a form download file.
find the method by pointing the file download to an iframe, sample code as follows
function downFile(url, method, params) {
var form = $("-sharpformDownload");
form.empty();
form.attr("method", method);
form.attr("action", url);
for ( var i in params) {
var param=params[i];
var input = $("<input>");
input.attr("type", "hidden");
input.attr("name", param.name);
input.attr("value", param.value);
form.append(input);
}
form.submit();
var oFrm = $("-sharpdownloadTarget")[0];
oFrm.onload = oFrm.onreadystatechange = function() {
console.log("wancheng");
if (this.readyState && this.readyState != "complete") return;
else {
onComplete();
}
}
}
however, when used in Typescript, it will show that the attribute onreadystatechang
does not exist on HTMLElement
. Referring to the data, it is said that you need to define the type of oFrm and change it to HTMLIFrameElement
. However, after the modification, it is prompted that the attribute onreadystatechange
does not exist on HTMLIFrameElement
. May I ask how to modify it?