网络编程 
首页 > 网络编程 > 浏览文章

html下载本地

(编辑:jimmy 日期: 2024/5/10 浏览:3 次 )

通过javascript 实现

index.html

<a href=# onclick="window.open('temp.html');return(false);">下载文件</a>

#######

temp.html  //被下载文件

  <Script language="javascript">
  if (typeof(window.opener) != 'undefined')   //判断 打开方式的下载。 去掉会一打开文件就弹出下载框
  {
   document.execCommand('SaveAs');
   window.close();
  }
  </Script> 

################

<button onclick="javascript:document.execCommand('SaveAs');">保存本页面</button>

上一篇:强制设为首页代码
下一篇:Javascript 小技巧全集第1/4页
友情链接:杰晶网络 DDR爱好者之家 南强小屋 黑松山资源网 白云城资源网