I have a virtual path开发者_Python百科 to a .wav file. I stored that value in a hidden field. Now when clicking a button i want to show a save dialog box for that virtual path .
i tried this
window.open(path, "", "");
But it opens file in media player .I just want to show save dialog so that u ser can select a place to store that file. Is it possible using jquery?
HTML5 introduces a new attribute, download
, that allows you to do this. Here's an example with an anchor tag:
<!-- On click opens a 'Save Dialog' for the href specified, and uses the filename specified in the download tag. -->
<a href="http://example.com/path/to/my/file.txt" download="file.txt" />
Triggering the download using JavaScript:
var clickEvent = document.createEvent("MouseEvent");
clickEvent.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
document.getElementById("anchor").dispatchEvent(clickEvent);
精彩评论