/    Sign up×
Community /Pin to ProfileBookmark

"Force" Download with User Approval

Hi,

We have links on our website that point directly to Excel spreadsheet files on our server. When the user clicks a link, It will display a dialog, asking if the user wants to Open or Save the file (standard browser procedure). I want to provide the same functionality, but with a dynamically created file.

For example, instead of a link, the screen will have a button. If the user clicks the button, a CSV file will be created and stored on the server. I then want to be able to immediately “download” that file, as if it were a link on the page and the user clicked it. So, they would then be shown the Open/Save dialog to give them the option to view or download the file. Any way to do that using JavaScript?

Thanks,

Tim

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@rnd_meNov 01.2011 — window.open(fileURL)
Copy linkTweet thisAlerts:
@tpdietzauthorNov 02.2011 — Excellent! Thanks! -Tim
×

Success!

Help @tpdietz spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...