我知道一些可能的方法和浏览器兼容性(基于快速测试):
1)使用指向新文件的
window.open
方法。- FireFox 3 blocks this.
- IE6 blocks this.
- IE7 blocks this.
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?
额外奖励:是否有一种方法不需要浏览器条件语句?
(我相信download.com有条件地使用这两种方法,但我无法使它们任何一种起作用。)
回应和澄清:
Q: "Why not point the current window to the file?"
A: That might work, but in this particular case, I want to show them some other content while their download starts - for example, "would you like to donate to this project?"
更新:我已经放弃了这种方法。请参见下面的答案以了解原因。