我希望用户能够从我的服务器下载这个 Excel 文件。单击“下载”按钮后必须有一种简单的方法来启动文件下载...但我不知道如何实现这一点。
到目前为止我有这个:(VBscript 和 ASP)
<head>
<script type="text/javascript" src="overzicht.js"></script>
</head>
Set fs=Server.CreateObject("Scripting.FileSystemObject")
if (fs.FileExists("c:\file.xls"))=true then 'fake filename D:
response.write("<input type='button' value='Download Masterfile' class='button' onclick='exportmasterfile();' /><br />")
else
response.write("Masterfile not found. <br />")
end if
set fs=nothing
javascript 函数为空。
最佳答案
实际上,如果您想要一种“更高效”(也更性感)的方式,请使用:
location.href = your_url;
这样一来,您将节省编译器一些时间,将其从 location
的原型(prototype)链上移至 window
对象。
关于javascript - 使用 Javascript 下载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/349067/