Home > Web Front-end > JS Tutorial > 通过修改referer下载文件的方法_JavaScript

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

WBOY
Release: 2016-05-16 19:04:49
Original
1872 people have browsed it

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: 
 
 
 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template