victor hugo
victor hugo

Reputation: 35848

Javascript or jQuery: Download and redirect

Currently some guys programmed this in a HTML page:

<script>
    location='http://example.com/downloadable.zip';
</script>

They want to redirect the user to another page once the file has started downloading. I can only modify this page but not the destination page.

What would be a good and clean javascript solution for making a user download the file and once he had accepted (or rejected) it, redirect him to another location? The solution may be jQuery code

NOTE: The downloading and redirection must be done automatically when accessing the page

Upvotes: 0

Views: 710

Answers (2)

Andres
Andres

Reputation: 5228

This seems like a hack. Have you tried an HTML meta tag with refresh? Also, you can add a link if the download fails.

Upvotes: 0

Eric
Eric

Reputation: 766

Perhaps setup a link that calls a function. The function would in turn then send the download link, and then redirect.

This is just a guess based upon your description, as I don't know the full general setup, but it's what I would do going on what I know.

Upvotes: 1

Related Questions