Prompt that the attribute "onreadystatechange" does not exist on type "HTMLIFrameElement". Ts (2339)

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?

Mar.21,2022

try this

    oFrm.onload = oFrm["onreadystatechange"] = function() {
        console.log("wancheng");
         if (this.readyState && this.readyState != 'complete') return;
         else {
             onComplete();
         }
    }

 var oFrm = <HTMLIFrameElement>document.getElementById('id');
        oFrm.onload = oFrm.onratechange = function() {
            console.log("wancheng");
             if (this.readyState && this.readyState != 'complete') return;
             else {
                 onComplete();
             }
        }

typescript related: assert < > as

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b9ea3a-439ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b9ea3a-439ab.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?