m.edmondson
m.edmondson

Reputation: 30872

Prompting for download

Whats the best method to prompt a user to download something? In the past I've used window.open('file.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?

Upvotes: 3

Views: 253

Answers (3)

Joachim VR
Joachim VR

Reputation: 2340

Redirect using javascript.

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

Upvotes: 3

Alin P.
Alin P.

Reputation: 44346

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.

Upvotes: 1

Quentin
Quentin

Reputation: 943510

Set a content disposition header with an attachment value

Upvotes: 0

Related Questions