下载使用JavaScript文件 [英] Download a file using Javascript

查看:290
本文介绍了下载使用JavaScript文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有就是我希望用户能够从我的服务器下载这个Excel文件。必须有启动文件的下载的下载按钮,点击后,一个简单的方法...但我不知道如何做到这一点。

There's this Excel file I want users to be able to download from my server. There must be an easy way to initiate the download of the file after a click on the "Download" button... but I have no clue how to make that happen.

我有这到目前为止:(VBScript和ASP)

I have this so far: (VBscript and 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函数是空的。

The javascript function is empty.

推荐答案

你不会相信这一点。
发现它...

you're not going to believe this. Found it...

function exportmasterfile()
{   var url='../documenten/Master-File.xls';    
    window.open(url,'Download');  
}

对不起你们!

这篇关于下载使用JavaScript文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆