I am using generated html that contains a link to a file with the .dxf
suffix:
<a href="http://example.com/filetodownload.dxf">Download File</a>
Since I can't change the dynamically created html, I'm using this to add the download attribute to those href links:
jQuery('a[href*=".dxf"]').each(function() {
jQuery("a").attr("download", "downloadedfile.dxf");
});
This forces the browser to open a "download and save" dialogue.
The problem is that I want the download attribute to have the name of the file in the link, i.e. filetodownload.dxf
and not the default downloadedfile.dxf
in the jQuery function.
How can I get jQuery to use the real file name? Can I call a variable that is the actual file name? How do I extract the file name from the link?
I don't want a box on the page to name the downloaded file, like Custom download name with Javascript or JQuery
I can't get the file name from the URL in the browser, since the file is a html download link, not a URL, like js function to get filename from url