0

I have a virtual path 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?

1

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.