Alvi_1987 Alvi_1987 - 5 months ago 124x
Javascript Question

Downloading file custom name with jquery

I am using a jQuery plugin to export HTML table to Excel. The downloaded file name using chrome is always

and using mozilla firefox it is
. I want file name to be created according to date. For example

Below is the custom JS block in view file

$(document).ready(function () {
$("#btnExport").click(function () {
containerid: "account_table",
datatype: $datatype.Table


You want to set the download and href attributes on the link. For example

$("#btnExport").click(function () {
        var uri = $("#account_table").btechco_excelexport({
            containerid: "account_table", 
            datatype: $datatype.Table,
            returnUri: true

        $(this).attr('download', 'ExportToExcel.xls') // set file name (you want to put formatted date here)
               .attr('href', uri)                     // data to download
               .attr('target', '_blank')              // open in new window (optional)