<div class="codetitle"> <span><a style="CURSOR: pointer" data="56493" class="copybut" id="copybut56493" onclick="doCopy('code56493')"><u>코드 복사</u></a></span> 코드는 다음과 같습니다.</div> <div class="codebody" id="code56493"> <br><html> 🎜>< ;title>js는 자동으로 로컬</title> <br><script 언어="javascript" type="text/javascript"> <br>함수 InitAjax() <br>{ <br> var ajax ; <br>if(window.ActiveXObject){ <br>var versions = ['Microsoft.XMLHTTP', 'MSXML.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.7.0', 'Msxml2.XMLHTTP .6.0 ', 'Msxml2.XMLHTTP.5.0', 'Msxml2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP'] <br>for(var i=0; i <versions. length; i ) { <BR>try { <BR>ajax = new ActiveXObject(versions[i]) <BR>if(ajax) { <BR>return ajax; {} <BR><BR>} <BR>}else if(window.XMLHttpRequest) <BR>{ <br>ajax = new XMLHttpRequest() <br>} <BR><BR>return ajax; } <BR>//JS는 자동으로 로컬 <BR>var xh; <br>function getXML(geturl) { <br>alert(geturl); <BR>xh = InitAjax() <BR>xh.onreadystatechange = getReady ; <BR>xh.open("GET", geturl, true); <BR>xh.send() <BR>} <BR><BR>function getReady() { <BR><BR>/ /alert(xh.readyState); <BR>if (xh.readyState == 4) { <br>alert(xh.status) <br>if (xh.status == 200) { <br>saveFile(" d: dd.gif"); <br>true를 반환; <BR>} <BR>else <BR>{ false를 반환; } <BR>} <BR>else <BR>false를 반환; <BR>} <BR><BR>function saveFile(tofile) { <BR>alert(tofile); <BR>var objStream; <BR>var imgs; <br>imgs = xh.responseBody; Stream" ); <br>objStream.Type = 1; <BR>objStream.open(); <BR>objStream.write(imgs); <BR>objStream.SaveToFile(tofile) <BR>} <BR>// getXML("http://10.76.3.116/2.bmp"); <BR>//js는 자동으로 파일을 로컬 끝에 다운로드합니다<BR></script> <br><br></head> <br>< ;body> <br><form id="form1" runat="server"> <br><div> <br><input type="button" value="124" onclick= "getXML(' http://img.jb51.net/images/dl.gif')"> <br></div> <br></form> ></html><br><br> </div>