<SCRIPT LANGUAGE="JavaScript">
function saveTo ()
{
var w = window.open("image001.gif");
w.document.execCommand('SaveAs', null, 'image001.gif');
w.close();
}
</script>
<img src="image001.gif" width="543" height="492" border=0 alt="click to save" onclick="saveTo()">
function saveTo ()
{
var w = window.open("image001.gif");
w.document.execCommand('SaveAs', null, 'image001.gif');
w.close();
}
</script>
<img src="image001.gif" width="543" height="492" border=0 alt="click to save" onclick="saveTo()">
解决方案 »
- jquery ajax返回值问题 请大虾们帮帮忙,这个问题折磨了我一下午
- fckeditor怎么设置默认的字体大小和颜色?
- 急送分·如何将表格中的每个<td>标签对中的checked选中或者取消?
- ExtractMenu一个不错的avaScript菜单,怎么实现延迟消失和顶级菜单?
- 举国欢庆放假的时候,再散分散代码 ★HostEditor★ 梅雪香
- 如何获取主页里包含的iframe的top边距和left边距
- 服务器被别人攻击,请教如何找出漏洞。
- 关于多个JavaScript的位置放置问题
- 函数返回值如何取到?
- 网页打印的问题!
- ■■请教,JS中定义变量,在网页中引用变量怎么不行啊,大家给看看,例如:■■
- 请问用正则表达式怎么表示如下条件的字符串
有歌大侠写的download的文件,可以直接传递参数给该文件,
然后该文件会提示用户保存指定得文件,而且可以下载ie都能默认显示
得word文档等。
<%@ Language=VBScript %>
<%
Dim filename
filename = Trim(Request("filename"))
if filename<>"" and not isnull(filename) then filename=Replace(Replace(filename,"/",""),"\","")
call downloadFile(filename)
Function downloadFile(strFile)
strFilename = server.MapPath(strFile)
Response.Buffer = True
Response.Clear
Set s = Server.CreateObject("ADODB.Stream")
s.Open
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(strFilename) then
Response.Write("<h1>Error:</h1>" & strFilename & " does not exist<p>")
Response.End
end if
' get length of file
Set f = fso.GetFile(strFilename)
intFilelength = f.size
s.LoadFromFile(strFilename)
if err then
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=" & f.name
Response.AddHeader "Content-Length", intFilelength
Response.CharSet = "UTF-8"
Response.ContentType = "application/octet-stream"
Response.BinaryWrite s.Read
Response.Flush
s.Close
Set s = Nothing
End Function
%>
〉〉可以,道理一样的。
to 一刺:
你的方法虽然有用,但是调用的是ie中另存为的功能。如果附件为操作系统未识别的文件类型,另存的时候可能导致文件后缀名改掉。另外还有弹出的对话框也是另存的窗口,最下面还有选择语言的项。
在ie中选中附件的时候,右键单击弹出菜单中有目标另存为一项,不知道大家能不能做到象这样的功能。