<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>