Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have a href link to a pdf file that when clicked on it downloads. I want this to just open in a new page instead of downloading.

<a href="../file/1012">clicking here</a>

I've had a look at a website that does this with iframe, but I would prefer not to use that.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
506 views
Welcome To Ask or Share your Answers For Others

1 Answer

Your server should return this http header:

Content-Type: application/pdf

For viewing in browser it should also return:

Content-Disposition: inline;filename="myfile.pdf"

For downloading:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...