您的位置:首页 > Web前端 > JavaScript

【转】js实现另存为的方法

2010-05-31 23:31 134 查看
示例代码:

<input type=button value=另存为 onclick="mm1()">

<iframe width=0 height=0 frameborder=0 name=hrong style="display: none"></iframe>
<script language="JavaScript">
//有窗口弹出的下载
/* function openfile()
{
var a;
a =window.open("下载文件的URL","_blank", "width=0, height=0");
a.document.execCommand("SaveAs");
a.close();
} */
//无窗口弹出

function mm1()
{
var str="下载文件的URL";
window.frames["hrong"].location.href = str;
sa();
}
function sa()
{
if(window.frames["hrong"].document.readyState!="complete")
setTimeout("sa()", 100);
else
window.frames["hrong"].document.execCommand('SaveAs');
}
</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: