How to forcefully download .csv file instead of getting in open on browser in html -


when click download button, link new webpage , after 2 sec start download .csv file sd card.

instead of downloading file, getting displayed on browser. below code.

how can download option every time? please no php code, new html.

i don't want save using save option after .csv file open browser.

    <!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 class="right">interface</div>                                                 <div class="left">overview</div>                                             </div>                                              <div id="content">                                                 <h1>monitoring system</h1>                                                  <table style="padding-left: 10px;">                                                     <div id="lcontent">                                                     <div id="llogindiv" ><h1>thanks downloading...</h1></div>                                                     <meta http-equiv="refresh" content="2;~geteventfile~;";>                                                 </table>                                              </div>                                         </div>                                         <div class="spacer">&nbsp;</div>                                         <div id="footer">copyright &copy; monitoring system</div>                                     </div>                                 </div>                             </div>                         </div>                     </div>                 </div>             </div>         </body>     </html> 

~geteventfile~ give me file name @ run time.

at point safe solution set response headers.

modern browsers support download attribute anchor elements used specify name of file downloaded:

<a href="http://sstatic.net/stackexchange/img/logos/so/so-logo.png" download="logo.png">download logo</a>


Comments