execScript(
'Function bytes2BSTR(vIn) \n'+
' Dim strReturn \n'+
' For ii = 1 To LenB(vIn) \n'+
' ThisCharCode = AscB(MidB(vIn,ii,1)) \n'+
' If ThisCharCode < &H80 Then \n'+
' strReturn = strReturn & Chr(ThisCharCode) \n'+
'Else \n'+
' NextCharCode = AscB(MidB(vIn,ii+1,1)) \n'+
' strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) \n'+
' ii = ii + 1 \n'+
' End If \n'+
' Next \n '+
' bytes2BSTR = strReturn \n'+
'End Function','VBScript');function XmlHttp(url){
var _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", url, true);
var _value = "";
this.getResult = function(){
return _value;
}
var _xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
_xmlDoc.async = false; this.getXMLResult = function(){
try{ _xmlDoc.loadXML(_value);
if(_xmlDoc.childNodes.length == 0)
throw new Error("不是标准格式的xml");
}catch(e){
throw new Error("不是标准格式的xml");
}
return _xmlDoc;
} this.onresult = function(){
} this.onException = function(){
} _xmlHttp.onreadystatechange = function() {
if(_xmlHttp.readyState != 4) return;
if (_xmlHttp.responseXML.parseError.errorCode == 0){
if(_xmlHttp.responseText.length)
_value = bytes2BSTR(_xmlHttp.responseBody);
else
_value = "";
this.onresult();
_xmlHttp.abort();
}
}; this.send = function(_string){
try{
_xmlHttp.send("<?xml version='1.0' encoding='utf-8'?>"+_string);
}
catch(e)
{
throw e
}
}
}
var xmlHttp = new XmlHttp(url);
xmlHttp.onresult = function (){
alert(this.getXMLResult());
}
xmlHttp.send();
'Function bytes2BSTR(vIn) \n'+
' Dim strReturn \n'+
' For ii = 1 To LenB(vIn) \n'+
' ThisCharCode = AscB(MidB(vIn,ii,1)) \n'+
' If ThisCharCode < &H80 Then \n'+
' strReturn = strReturn & Chr(ThisCharCode) \n'+
'Else \n'+
' NextCharCode = AscB(MidB(vIn,ii+1,1)) \n'+
' strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) \n'+
' ii = ii + 1 \n'+
' End If \n'+
' Next \n '+
' bytes2BSTR = strReturn \n'+
'End Function','VBScript');function XmlHttp(url){
var _xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlHttp.open("POST", url, true);
var _value = "";
this.getResult = function(){
return _value;
}
var _xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
_xmlDoc.async = false; this.getXMLResult = function(){
try{ _xmlDoc.loadXML(_value);
if(_xmlDoc.childNodes.length == 0)
throw new Error("不是标准格式的xml");
}catch(e){
throw new Error("不是标准格式的xml");
}
return _xmlDoc;
} this.onresult = function(){
} this.onException = function(){
} _xmlHttp.onreadystatechange = function() {
if(_xmlHttp.readyState != 4) return;
if (_xmlHttp.responseXML.parseError.errorCode == 0){
if(_xmlHttp.responseText.length)
_value = bytes2BSTR(_xmlHttp.responseBody);
else
_value = "";
this.onresult();
_xmlHttp.abort();
}
}; this.send = function(_string){
try{
_xmlHttp.send("<?xml version='1.0' encoding='utf-8'?>"+_string);
}
catch(e)
{
throw e
}
}
}
var xmlHttp = new XmlHttp(url);
xmlHttp.onresult = function (){
alert(this.getXMLResult());
}
xmlHttp.send();
{
string Url = "http://dotnet.aspx.cc/Images/logoSite.gif";
string StringFileName = Url.Substring(Url.LastIndexOf("/") + 1);
string StringFilePath = Request.PhysicalApplicationPath;
if(!StringFilePath.EndsWith("/")) StringFilePath += "/";
MSXML2.XMLHTTP _xmlhttp = new MSXML2.XMLHTTPClass();
_xmlhttp.open("GET",Url,false,null,null);
_xmlhttp.send("");
if( _xmlhttp.readyState == 4 )
{
if(System.IO.File.Exists(StringFilePath + StringFileName))
System.IO.File.Delete(StringFilePath + StringFileName);
System.IO.FileStream fs = new System.IO.FileStream(StringFilePath + StringFileName, System.IO.FileMode.CreateNew);
System.IO.BinaryWriter w = new System.IO.BinaryWriter(fs);
w.Write((byte[])_xmlhttp.responseBody);
w.Close();
fs.Close();
Response.Write ("文件已经得到。<br><a href='" + Request.ApplicationPath + StringFileName +"' target='_blank'>");
Response.Write ("查看" + StringFileName + "</a>");
}
else
Response.Write (_xmlhttp.statusText);
Response.End();
}
中用到了XMLHTTP的,你可以看看它的源码。对不同的浏览器的处理也已经封装了。