Opening a new tab to read a PDF file
<a href="newsletter_01.pdf" target="_blank">Read more</a>
Target _blank will force the browser to open it in a new window
As everyone else has pointed out, this can work:
<a href="newsletter_01.pdf" target="_blank">Read more</a>
But what nobody has pointed out is that it's not guaranteed to work.
There is no way to force a user's browser to open a PDF file in a new tab. Depending on the user's browser settings, even with target="_blank"
the browser may react the following ways:
- Ask for action
- Open it in Adobe Acrobat
- Simply download the file directly to their computer
Take a look at Firefox's settings, for example:
Chrome has a similar setting:
If the user has chosen to "Save File" in their browsers settings when encountering a PDF, there is no way you can override it.
An observation, _blank
alone will not make sure the file is opened in a new tab. The response header for the file request should have Content-Type : application/pdf
.
Try this link, it will open the file in new tab as the server provide required headers.
Same is the case for other file types also. For ex: video files get request should have proper Content-Type
like video/mp4
.