它不会下载文件,而是显示在浏览器上.以下是我的代码.
我怎样才能每次都获得下载选项?请不要PHP代码,因为我是HTML的新手.
我不想在.csv文件打开浏览器后使用另存为选项保存.
<!DOCTYPE HTML PUBliC "-//W3C//DTD xhtml 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <HTML xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <Title>Monitoring System</Title> <link href="/mchp.CSS" rel="stylesheet" type="text/CSS" /> <script src="/mchp.Js" type="text/JavaScript"></script> </head> <body> <div ID="shadow-one"> <div ID="shadow-two"> <div ID="shadow-three"> <div ID="shadow-four"> <div ID="page"> <div> <div> <div> <div ID="Title"> <div >Interface</div> <div >OvervIEw</div> </div> <div ID="content"> <h1>Monitoring System</h1> <table > <div ID="lcontent"> <div ID="llogindiv" ><h1>Thanks for downloading...</h1></div> <Meta http-EQUIV="refresh" CONTENT="2;~GetEventfile~;";> </table> </div> </div> <div > </div> <div ID="footer">copyright © Monitoring System</div> </div> </div> </div> </div> </div> </div> </div> </body> </HTML>
~GetEventfile~会在运行时给我文件名.
解决方法 此时,安全的解决方案是设置响应头.Modern browsers支持anchor元素的下载属性,用于指定将要下载的文件名称:
<a href="http://sstatic.net/stackexchange/img/logos/so/so-logo.png" download="logo.png">Download SO logo</a>总结
以上是内存溢出为你收集整理的如何强制下载.csv文件,而不是在html中的浏览器上打开全部内容,希望文章能够帮你解决如何强制下载.csv文件,而不是在html中的浏览器上打开所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)