php - Best way to initiate a download? -


on php-based web site, want send users download package after have filled out short form. site-initiated download should similar sites download.com, "your download begin in moment."

a couple of possible approaches know about, , browser compatibility (based on quick test):

1) window.open pointing new file.

- firefox 3 blocks this.    - ie6 blocks this.    - ie7 blocks this. 

2) create iframe pointing new file.

- firefox 3 seems think ok. (maybe it's because accepted once?)    - ie6 blocks this.    - ie7 blocks this.  how can @ least these 3 browsers not object?  

bonus: there method doesn't require browser-conditional statements?

(i believe download.com employs both methods conditionally, can't either 1 work.)

responses , clarifications:

q: "why not point current window file?"   a: might work, in particular case, want show them other content while download starts - example, "would donate project?" 

update: have abandoned approach. see answer below reasons.

you can meta refresh, browsers support. download.com places 1 in noscript tag.

<meta http-equiv="refresh" content="5;url=/download.php?doc=123.zip"/> 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -