excel - Jquery html to xls code doesn't work on IE and FireFox -
hi trying implement jquery code html work on chrome, ie , firefox doesen't work, havent got enough javascript experience find please help.
i tried change quotation marks on javascript doesent work too.
<html> <head> <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js></script> <script> $(document).ready(function() { $("#btnexport").click(function(e) { //getting values of current time generating file name var dt = new date(); var day = dt.getdate(); var month = dt.getmonth() + 1; var year = dt.getfullyear(); var hour = dt.gethours(); var mins = dt.getminutes(); var postfix = day + "." + month + "." + year + "_" + hour + "." + mins; //creating temporary html link element (they support setting file names) var = document.createelement('a'); //getting data our div contains html table var data_type = 'data:application/vnd.ms-excel'; var table_div = document.getelementbyid("dvdata"); var table_html = table_div.outerhtml.replace(/ /g, '%20'); a.href = data_type + ', ' + table_html; //setting file name a.download = 'exported_table_' + postfix + '.xls'; //triggering function a.click(); //just in case, prevent default behaviour e.preventdefault(); }); }); </script> </head> <body> <div id="dvdata"> <table border="0" cellspacing="2" cellpadding="10"> <tr> <td>tarih</td> <td>abd</td> <td>afganistan</td> <td>almanya</td> </tr> <tr> <td>1993</td> <td>100</td> <td>200</td> <td>300</td> <tr> <tr> <td>1994</td> <td>250</td> <td>340</td> <td>460</td> </tr> </table> </div> <button id="btnexport">click save</button> </body> </html>
Comments
Post a Comment