iframe
const iframe = document. createElement ( "iframe" ) ;
iframe. style. display = "none" ;
iframe. src = url;
document. body. appendChild ( iframe) ;
setTimeout ( ( ) => {
iframe. remove ( ) ;
} , 5 * 60 * 1000 ) ;
a
const a = document. createElement ( 'a' ) ;
a. style. display = 'none' ;
a. download = '<文件名>' ;
a. href = url;
a. click ( ) ;
document. body. removeChild ( a) ;
form
let form = document. createElement ( 'FORM' ) ;
form. setAttribute ( 'method' , 'get' ) ;
form. setAttribute ( 'action' , url) ;
document. body. appendChild ( form) ;
form. submit ( ) ;
window
window. open ( url) ;
window. location. href = url;
带参数的 post
const form = document. createElement ( 'form' ) ;
form. setAttribute ( 'style' , 'display:none' ) ;
form. setAttribute ( 'target' , '_blank' ) ;
form. setAttribute ( 'method' , 'post' ) ;
form. setAttribute ( 'action' , url) ;
const input = document. createElement ( 'input' ) ;
input. setAttribute ( 'type' , 'hidden' ) ;
input. setAttribute ( 'name' , 'data' ) ;
input. setAttribute ( 'value' , JSON . stringify ( params) ) ;
document. body. appendChild ( form) ;
form. appendChild ( input) ;
form. submit ( ) ;
form. remove ( ) ;