I'm building some content from my json response on the client side to display in a html table. I also have a download button, which up on clicking should be saving the file to local disk. I'm creating the csvContent from the same json response on the fly.
code :
<a class="download-page" href="#" onClick="downloadPage();">Download</a>
function downloadPage() {
window.location.href = 'data:text/csv;charset=UTF-8,'+ encodeURIComponent(csv);
//window.location.href = "data:text/csv;charset=utf-8," + escape(csv));
//window.open("data:text/csv;charset=utf-8," + encodeURI(csv))
}
This works only in chrome 10. Some versions of browser doesn't support this at all. IE is a big problem. But most of my users use IE 9 and Fire fox. Is there any cross browser functionality to attain this.
Sample CSV data:
"Testcase Reports for : jumashan\r\n
Total Unique Stimuli : 1\r\n
Total execution time : 0 Days 0 hours 16 minutes\r\n
Testcase Name, Count (Pass/Fail/Error/Block), Version Number, Execution Time(HH:MM:SS),
INIT-CHECK,2( 0 / 0 / 0 / 2 ) ,0,0:16:28,
Testcase Reports for : prabhaa\r\n
Total Unique Stimuli : 1\r\n
Total execution time : 0 Days 1 hours 23 minutes\r\n"