The world file link returned by the backend, how can the front end be downloaded locally?

The

backend now returns an address. You can download it by yourself if you open it directly in the browser, but how to download it with jsIE? What does the back end mean by using iframe?

Mar.20,2021

if the document is connected

add the following code to the callback function of the interface

var a = document.createElement('a');
a.href = url;
a.download = 'test.word';
a.click();

if you return a document, you can use fetch to receive and download

 fetch("/api", { credentials: 'include' }).then(x => x.blob()).then(x => {
            var a = document.createElement('a');
            var url = window.URL.createObjectURL(x);   //  blob  (blob )
            a.href = url;
            a.download = 'test.pdf';
            a.click();
            window.URL.revokeObjectURL(url);
        })

you can download the file through the src attribute in the iframe tag. Src is the url, returned to the front end by the background. It is written as follows:

               
function downloadFile(url) {   
        try{ 
            var elemIF = document.createElement("iframe");   
            elemIF.src = url;   
            elemIF.style.display = "none";   
            document.body.appendChild(elemIF);   
        }catch(e){ 
        } 
    }
<input type="button" value="1" onClick = "downloadFile('http://')">
Menu