首页 > web前端 > js教程 > 正文

通过修改referer下载文件的方法_JavaScript

WBOY
发布: 2016-05-16 19:04:49
原创
1815 人浏览过

GetFile.wsc

复制代码 代码如下:

 
 
   
   
     
     
     
     
       
    
 
     
       
    
 
  
 
   
     
  
 
   
  <script> <BR> <![CDATA[ <BR>var Referer, Content, Data; <BR>var Stream = new ActiveXObject("ADODB.Stream"); <BR>Stream.Type = 1; <BR>function onReady() <BR>{ <BR> if(Http.readyState == 4) <BR> { <BR> Content = Http.responseText; <BR> Data = Http.responseBody; <BR> fireEvent("ondowncomplete"); <BR> Http.abort(); <BR> } <BR>} <BR>function GetFile(URL) <BR>{ <BR> Http.onreadystatechange = onReady; <BR> Http.open("GET", URL, true, "", ""); <BR> if(Referer) Http.setRequestHeader("Referer", Referer); <BR> Http.send(null); <BR>} <BR>function Save(Path) <BR>{ <BR> Stream.Open(); <BR> Stream.Write(Data); <BR> Stream.SaveToFile(Path, 2); <BR> Stream.Close(); <BR>} <BR> ]]> <BR> </script> 
  

test.hta
复制代码 代码如下:

<script> <BR>var Down = document.createElement("Comment"); <BR>document.lastChild.lastChild.appendChild(Down); <BR>Down.style.behavior="url(GetFile.wsc)"; <BR>Down.ondowncomplete = function() <BR>{ <BR> //document.write(Down.Content); <BR> Down.Save(SaveTo.value); <BR> Go.disabled=0; <BR> alert("OK"); <BR>} <BR>function GetFile() <BR>{ <BR> Go.disabled = 1; <BR> Down.Referer = Referer.value; <BR> Down.GetFile(URL.value); <BR>} <BR></script> 
 
URL: 
 
Referer: 
 
SaveTo: 
 
 
 
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板