开发者

Prompting for download

开发者 https://www.devze.com 2023-01-19 10:58 出处:网络
Whats the best method to prompt a user to download something?In the past I\'ve used window.open(\'f开发者_Python百科ile.pdf\'); but I can see popup blockers having a problem with this.Of course I\'ll

Whats the best method to prompt a user to download something? In the past I've used window.open('f开发者_Python百科ile.pdf'); but I can see popup blockers having a problem with this. Of course I'll include a manual link aswel.

I basically want something like the Microsoft Download page. So whats the script that prompts this?


Redirect using javascript.

function redirect() {
window.location = 'http://www.url.to/your.file';
}


Content-Disposition: attachment; filename="file.pdf"

To do this you may want to pass your file.pdf through a server script that forces that header on it.

What you see on that download page is just a location change. And if that page returns the download header the browser won't change page.


Set a content disposition header with an attachment value

0

精彩评论

暂无评论...
验证码 换一张
取 消