【转】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>
<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>
相关文章推荐
- JS实现点击文字对应DIV层不停闪动效果的方法
- js跨浏览器实现将字符串转化为xml对象的方法
- js实现两点之间画线的方法
- js实现canvas保存图片为png格式并下载到本地的方法
- iOS JS 交互之利用系统JSContext实现 JS调用OC方法以及Objective-C调用JavaScript方法
- JS实现字符串翻转的方法分析
- JS实现遍历不规则多维数组的方法
- JS实现拖拽的方法分析
- [置顶] 【javascript 画进度条】js实现进度条的方法
- 表单数据验证方法(一)—— 使用validate.js实现表单数据验证
- 原生JS实现动态加载js文件并在加载成功后执行回调函数的方法
- js toFixed()方法的重写实现精度的统一
- JS操作COOKIE实现备忘记录的方法
- js 实现一些跨浏览器的事件方法详解及实例
- 实现js的replaceAll方法
- Vue.js实现表格渲染的方法
- JS实现同时搜索百度和必应的方法
- js实现简单随机抽奖的方法
- js判断文件类型大小并给出提示的实现方法
- js+CSS实现弹出居中背景半透明div层的方法