在基于PHP的网站上,我想在填写简短表单后向用户发送下载包.网站启动的下载应该类似于download.com这样的网站,它们说"你的下载将在一瞬间开始".
我知道的几种可能的方法和浏览器兼容性(基于快速测试):
1)window.open指向新文件.
- FireFox 3 blocks this.
- IE6 blocks this.
- IE7 blocks this.
Run Code Online (Sandbox Code Playgroud)
2)创建指向新文件的iframe.
- FireFox 3 seems to think this is OK. (Maybe it's because I already accepted it once?)
- IE6 blocks this.
- IE7 blocks this.
How can I do this so that at least these three browsers will not object?
Run Code Online (Sandbox Code Playgroud)
额外奖励:有没有一种方法不需要浏览器条件语句?
(我相信download.com有条件地使用这两种方法,但我不能让任何一种方法工作.)
回应和澄清:
Q: "Why not point the current window to the file?"
A: That might work, but in …Run Code Online (Sandbox Code Playgroud)