<script?language=
"javascript"
?type=
"text/javascript"
>
//js自动下载文件到本地
var
?xh;
function
?getXML(geturl)
{
????
//alert("ll");
????
xh?=?
new
?ActiveXObject(
"Microsoft.XMLHTTP"
);
????
xh.onreadystatechange?=?getReady;
????
xh.open(
"GET"
,geturl,
true
);????????????????????
????
xh.send();?????????????????????????
}
?
function
?getReady()
{
????
alert(xh.readyState);
????
if
(xh.readyState==4)
????
{
????????
if
(xh.status==200){
????????????
saveFile(
"d:\mm.exe"
);
????????????
return
?true
;
????????
}
????????
else
????????
{
return
?false
;}
????
}
????
else
????????
return
?false
;
}
?
function
?saveFile(tofile)
{
????
var
?objStream;
????
var
?imgs;
????
imgs?=?xh.responseBody;?
????
objStream?=?
new
?ActiveXObject(
"ADODB.Stream"
);
????
objStream.Type?=?1;
????
objStream.open();
????
objStream.write(imgs);
????
objStream.SaveToFile(tofile)
}
getXML(
"http://192.168.22.206/servlet"
);?
?
</script>
saveFile("d:\mm.jpg");
这个里面赋给它保存到本地的文件名称;
getXML("http://192.168.22.206/servlet");?
用这个方法调用自己写好的servlet,里面赋给自己定义的servlet名称。