javascript实现将文件保存到本地方法汇总

<script type="text/javascript"> function saveFile(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> </head> <body> <img src="https://www.jb51.net/mytest.jpg"> <a href="#"> 点击这里下载图片 </a> </body> </html>

方法二:

function SaveAs5(imgURL) { var Pop = 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(); } <img src="https://www.jb51.net/t_screenshot_17616.jpg">

方法三:

function SaveAs5(imgURL) { var Pop = 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(); } <img src="https://www.jb51.net/t_screenshot_17616.jpg"> <a href="#"> 点击这里下载图片 </a>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgdzyf.html