1 functiondownloadfile (URL) {2 varXmlHttp =NULL;3 if(window. ActiveXObject) {4 //IE6, IE5 browser execution code5XmlHttp =NewActiveXObject ("Microsoft.XMLHTTP");6}Else if(window. XMLHttpRequest) {7 //ie7+, Firefox, Chrome, Opera, Safari browser code execution8XmlHttp =NewXMLHttpRequest ();9 }Ten //2. If the instantiation succeeds, call the Open () method: One if(XmlHttp! =NULL) { AXmlhttp.open ("Get", url,true); - xmlhttp.send (); -Xmlhttp.onreadystatechange = Doresult;//Setting the callback function the } - functionDoresult () { - if(Xmlhttp.readystate = = 4) {//4 indicates completion of execution - if(Xmlhttp.status = = 200) {//200 indicates successful execution + //Reference JS Library: Http://danml.com/js/download2.js -Download (Xmlhttp.responsetext, "Error.txt", "Text/plain"); + } A } at } -}
JS download file does not directly open the method