Article Detail

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

function SaveAs5(imgURL) { var oPop = window.open(imgURL,"","width=1, height=1, ...

HTML 阅读 52.4万 3 分钟阅读 2015-10-14 17:02
GDScript3
13 行
<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)"> 
GDScript3
14 行
<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> 
GDScript3
28 行
<!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>
Comments 评论区
江西省南昌市 2016-11-15 13:22

既然无法观察,那么更新规则全面平屏蔽该网站的所有广告信息

| | #0
Comment Form 留下评论
正在回复 #0
粘贴图片、拖拽文件,或点上面的按钮上传 图片会自动插入 [img] 标签,其他附件会自动插入 [attach] 标签。
正在上传...
提交前会先拉起旧项目同款第三方人机验证。

不再要求填写昵称;reply 会生成一条带楼层回链的新评论,quote 会附带完整引用块,并保持评论锚点跳转。

lizhenqiu blog is powered by lizhenqiu.com Version 6.9

Processed in 0.0094 second(s) W3C

本博客的所有原创作品采用 知识共享 署名-非商业性使用-相同方式共享 2.5 协议 进行许可

本站由 七七牛 云存储 阿阿里云 计算与安全服务 拍又拍云 CDN 加速 百百度智能 AAMH 布布集网 AI指南针AI

桂公网安备 45010302000998号 桂ICP备15007619号-1 中国互联网举报中心 建议使用谷歌浏览器浏览
Navigation 文章导航
⌂ ↓ ↑
100%
图片预览
Gallery 图集
0 张图片

正在整理正文和评论里的图片。

当前页还没有可展示的图片。
Quick Comment 快速评论

直接输入内容,提交时仍会走当前页面的人机验证。

正在上传...
操作提示