正文 2336字数 510,974阅读

<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" onclick="SaveAs5(this.src)">
Run code
Cut to clipboard


    <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="#" onclick="SaveAs5(document.getElementById('DemoImg').src)"> 点击这里下载图片 </a>
    Run code
    Cut to clipboard


      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title></title> </head> <body> <script> function saveFile(T,content) {//保存 var filename=document.getElementById(T).value; var win=window.open('','','top=10000,left=10000'); win.document.write(document.getElementById(content).innerHTML); win.document.execCommand('SaveAs','',filename) win.close(); } </SCRIPT> <form name="saveas" action="" method="post"> 文件名称:<input type="text" id="title_1" value="123.html"> <br> 文件内容:<textarea id="content_1" style="height:150px;width:400px;"> 新兴网络 - http://www.newxing.com/ </textarea> <br> <input type="button" value="保存文本" onClick=saveFile('title_1','content_1')> </form> </body> </html>
      Run code
      Cut to clipboard