javascript 保存文件到本地实现方法
发布时间:2016-12-30 来源:查字典编辑
摘要:2种形式都可以第一种:复制代码代码如下:functionSaveAs5(imgURL){varoPop=window.open(imgURL...
2种形式都可以
第一种:
复制代码 代码如下:
<script>
function SaveAs5(imgURL)
{
var oPop = window.open(imgURL,"","width=1, height=1, top=5000, left=5000");
for(; oPop.document.readyState != "complete"; )
{
if (oPop.document.readyState == "complete")break;
}
oPop.document.execCommand("SaveAs");
oPop.close();
}
</script>
<img src="t_screenshot_17616.jpg" id="DemoImg" border="0">
第二种:
复制代码 代码如下:
<script>
function SaveAs5(imgURL)
{
var oPop = window.open(imgURL,"","width=1, height=1, top=5000, left=5000");
for(; oPop.document.readyState != "complete"; )
{
if (oPop.document.readyState == "complete")break;
}
oPop.document.execCommand("SaveAs");
oPop.close();
}
</script>
<img src="../t_screenshot_17616.jpg" id="DemoImg" border="0">
<a href="#"> 点击这里下载图片 </a>