【请教】关于下载文件的保存 新手求问,在点击文件的下载链接后,有没有办法能获取并改变另存为对话框中默认的文件名称?若能,最好附上部分代码,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这是坛子里->awsbamboo115写的,主要是js的execCommand<html><script language="Javascript" >function saveFile(T,content){ var filename=document.all(T).value; var win=window.open('','','top=10000,left=10000'); win.document.write(document.all(content).innerText); win.document.execCommand('SaveAs','',filename+".txt") win.close();}</script><body><form name="saveas" action="" method="post">文件名称:<input type="text" id="title_1"><br>文件内容:<textarea id="content_1">网站制作学习网</textarea><br><input type="button" value="save as txt file" onClick=saveFile('title_1','content_1')></form></body></html> 要看你怎么做了。java 是有输出流的。 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); response.setContentType("application/octet-stream"); response.setHeader("Content-length", workbook.getBytes() + ""); String filename = new String((sdf.format(new Date()) + ".xls") .getBytes("GBK"), "iso8859-1"); response.setHeader("Content-disposition", "attachment; filename=" + filename); 谢谢,但我所有的只是类似于http://ishare.iask.sina.com.cn/download/explain.php?fileid=62142415这样的链接,点击链接后会直接出现另存为的窗口,这时在另存为的窗口里面已经有了一个默认的文件名,是否能修改这个文件名? <a href="http://server/site/test.txt" download="test001.txt">Download Your File</a>目前好像只有Chrome支持。http://stackoverflow.com/questions/7428831/javascript-rename-file-on-download 这个对于上面的链接有效,很感谢!可是对于http:xxx/uploadFile/downloadFile.jsp?module_id=xxx&filePath=xxx&file_id=xxx这样的链接好像没什么用啊?每次下载的时候都会在文件名后面带一串数字,不想每次手动删除,想写一个自动删除的脚本 谢谢,但我所有的只是类似于http://ishare.iask.sina.com.cn/download/explain.php?fileid=62142415这样的链接,点击链接后会直接出现另存为的窗口,这时在另存为的窗口里面已经有了一个默认的文件名,是否能修改这个文件名?网页里有个网页名称的 你写什么点击下 就以什么保存 你可以写个get参数 然后定义个数组 从里面取啊 !!! 新浪的好像是用的 jQuery 不是很熟 http://ishare.iask.sina.com.cn/js/savevdisk-1.1.js svg 中 关于contextMenu这个右键菜单 类 关于EXCEL导入问题 js读取XML问题 请教一个简单的正则表达式 打印 vml问题:在group中画折线,折线坐标超出了group坐标范围,也能画出来,怎样限制其在group内,超出的部分直接裁掉 谁能帮我实现这种的功能TEXTAREA? 一个遍历text控件的问题 void(0)什么意思!vSrc = window.event.srcElement;什么意思一定要说说event对象的意义和内容 如何用正则表达式匹配两段字符串长度之和为一个固定值 前台如何获取json传过来的值 关于jquery对象的疑惑
<script language="Javascript" >
function saveFile(T,content)
{
var filename=document.all(T).value;
var win=window.open('','','top=10000,left=10000');
win.document.write(document.all(content).innerText);
win.document.execCommand('SaveAs','',filename+".txt")
win.close();
}
</script>
<body>
<form name="saveas" action="" method="post">
文件名称:<input type="text" id="title_1">
<br>
文件内容:<textarea id="content_1">
网站制作学习网
</textarea>
<br>
<input type="button" value="save as txt file" onClick=saveFile('title_1','content_1')>
</form>
</body>
</html>
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
response.setContentType("application/octet-stream");
response.setHeader("Content-length", workbook.getBytes() + "");
String filename = new String((sdf.format(new Date()) + ".xls")
.getBytes("GBK"), "iso8859-1");
response.setHeader("Content-disposition", "attachment; filename="
+ filename);
http://stackoverflow.com/questions/7428831/javascript-rename-file-on-download
网页里有个网页名称的 你写什么点击下 就以什么保存 你可以写个get参数 然后定义个数组 从里面取啊 !!!
http://ishare.iask.sina.com.cn/js/savevdisk-1.1.js