download behavior从msdn找了以下例子好像也只能download本域的文件, 把download.htm随便改成http://www.csdn.net就不行了 XMLHTTP该怎么用? <HTML XMLNS:IE><SCRIPT> function onDownloadDone(s) { alert (s); } </SCRIPT><IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" /> <P>Click <A HREF="javascript:oDownload.startDownload('download.htm', onDownloadDone)">here</A> to begin downloading this page.
parent, top: 在新版本的 IE 中, 好象不支持 top 对象了.
xmlhttp: <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=gb2312"> <script language="vbscript"> Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode strReturn = ""
For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode < &H80 Then strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next
bytes2BSTR = strReturn
End Function </script> <script language="JavaScript"> function getXML(URL) { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.Open("GET",URL, false); try { xmlhttp.Send(); var result = xmlhttp.status; } catch(e) { return(false); } if(result==200) { return(bytes2BSTR(xmlhttp.responseBody)); } var xmlhttp = null; } function update() { //alert("页面开始更新"); document.body.innerHTML = getXML('http://news.sohu.com/59/31/subject207263159.shtml'); } setInterval("update()",1000) </script> </head> <body> </body> </html>
把download.htm随便改成http://www.csdn.net就不行了
XMLHTTP该怎么用?
<HTML XMLNS:IE><SCRIPT>
function onDownloadDone(s) { alert (s); }
</SCRIPT><IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<P>Click <A HREF="javascript:oDownload.startDownload('download.htm',
onDownloadDone)">here</A> to begin downloading this page.
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="vbscript">
Function bytes2BSTR(vIn) Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
</script>
<script language="JavaScript">
function getXML(URL) {
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.Open("GET",URL, false);
try {
xmlhttp.Send();
var result = xmlhttp.status;
}
catch(e) {
return(false);
}
if(result==200) {
return(bytes2BSTR(xmlhttp.responseBody));
}
var xmlhttp = null;
}
function update()
{
//alert("页面开始更新");
document.body.innerHTML = getXML('http://news.sohu.com/59/31/subject207263159.shtml');
}
setInterval("update()",1000)
</script>
</head>
<body>
</body>
</html>