Prompting for download
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
精彩评论