〖另存为〗命令的实现
[格式]:document.execCommand("saveAs")
[说明]将该网页保存到本地盘的其它目录!
[举例]在<body></body>之间加入:
<a href="#" onclick=document.execCommand("saveAs")>另存为</a>
[格式]:document.execCommand("saveAs")
[说明]将该网页保存到本地盘的其它目录!
[举例]在<body></body>之间加入:
<a href="#" onclick=document.execCommand("saveAs")>另存为</a>
' 文件下载组件
' COPY 2002.8.29
' 要专门提供一个页来下载可以是隐藏的iframe,比直接下载要慢,但可以在下载前提供安全保证
' 并且存放路径不必为HTTP可以访问的路径
' 参数是一个绝对的路径和下载后的存盘文件名
'---------------------------------------------------------------------------------------------
Function TransferFile(pathandfilename, filename)
Dim objFileSystem, objFile, objStream
Dim schar
Dim sent
sent = 0
TransferFile = True Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objFile = objFileSystem.GetFile(pathandfilename)
Set objStream = objFile.OpenAsTextStream(1, -1) Response.AddHeader "content-type", "application/x-msdownload"
Response.AddHeader "Content-Disposition", "attachment;filename=" & filename
Response.AddHeader "content-length", objFile.Size Do While Not objStream.AtEndOfStream
schar = objStream.Read(1)
Response.BinaryWrite (schar)
sent = sent + 1
If (sent Mod 16384) = 0 Then
Response.Flush
If Not Response.IsClientConnected Then
TransferFile = False
Exit Do
End If
End If
Loop Response.Flush
If Not Response.IsClientConnected Then TransferFile = False objStream.Close
Set objStream = Nothing
Set objFileSystem = Nothing
End Function