弹出文件保存对话框

dtb 2004-11-02 10:30:21
有些人机上装了office,只要一点击doc文件就直接在ie打开
我现在不想让doc文件直接打开,而是弹出一个文件保存对话框,要怎么实现 用javascript?
...全文
238 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tianch 2004-11-02
  • 打赏
  • 举报
回复
楼上说得对,以下是ASP的代码
<%filename="yourpath"
' create stream
Set s = Server.CreateObject("ADODB.Stream")
s.Open

' Set as binary
s.Type = 1

' load in the file
on error resume next

' check the file exists
Set fso = Server.CreateObject("Scripting.FileSystemObject")
if not fso.FileExists(Filename) then
'Err = filename & " 此文件未找到!"
Response.Write("<h1>Error:</h1>" & Filename & " 此文件未找到!<p>")
Response.End
end if

' get length of file
Set f = fso.GetFile(Filename)
intFilelength = f.size

s.LoadFromFile(Filename)
if err then
'Err = err.Description
Response.Write("<h1>Error: </h1>" & err.Description & "<p>")
Response.End
end if

' send the headers to the users browser
Response.AddHeader "Content-Disposition", "attachment; filename=" & sourcefilename
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"

' output the file to the browser
Response.BinaryWrite s.Read
Response.Flush

' tidy up
s.Close
Set s = Nothing
%>
mrshelly 2004-11-02
  • 打赏
  • 举报
回复
javascript 应该不能实现。
~~~
这个要修改文件头信息的。所以,JS不能实现~~~

87,997

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧