For example, I have a pdf file link like this:
https://boliden.chemsoft.eu/BlackBoxInterface.aspx?output=doc&id=20647&filesekv=85858&filename=Zinc_2015-06-01_English.pdf.
If I create a link
<a href="https://boliden.chemsoft.eu/BlackBoxInterface.aspx?output=doc&id=20647&filesekv=85858&filename=Zinc_2015-06-01_English.pdf">Pure zink, Zinc_2015-06-01_English.pdf</a>
When I click this link, instead of showing the pdf file, the browser download it automatically.
So is there any way to open that PDF file using js?
Asked
Active
Viewed 422 times
-1
-
1Possible duplicate of [How to force files to open in browser instead of download (pdf)?](https://stackoverflow.com/questions/6293893/how-to-force-files-to-open-in-browser-instead-of-download-pdf) – Filnor Nov 10 '17 at 07:12
-
Because the link downloads the PDF automatically, nothing you can do about that ... if you had a static PDF file then what you're doing would work and the PDF file would be automatically opened. If you add `target="_blank"` to your `` then it would also be opened in another window rather then in current one. – anteAdamovic Nov 10 '17 at 07:21
-
thanks you all, i got it – An Vo Nov 13 '17 at 02:47
1 Answers
0
You could force the display of the PDF by using a library like PDF.js.
Otherwise, the user's browser will decide to either download or display the PDF document (assuming you do not send a force-download
header).
-- EDIT
Following Barmar's comment, you indeed need to remove the Content-disposition: attachment
header to let the browser decide.

nicovank
- 3,157
- 1
- 21
- 42
-
1It looks like the server is sending `Content-disposition: attachment`, which forces a download. – Barmar Nov 10 '17 at 07:12
-