views:

127

answers:

2

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

+1  A: 

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.

Eric
Thanks Eric there's no general setup, it's just a single HTML page with that behaviour. I thought about the link but the redirection must be done automatically so I'm not sure
victor hugo
Well, when the user visits the page, is it on a basis of they visit the page and the download instantly starts up?
Eric
Yes sir..........
victor hugo
Well then, why not just have the page redirect after x seconds? With the way modern browser works, once the download request is there, the page can continue moving.
Eric
A: 

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

Andres