Opening a new tab to read a PDF file

后端 未结 9 1051
广开言路
广开言路 2021-02-06 21:39

I am probably missing something simple here, however i will ask anyway. I have made a link to open up a PDF file, however it opens up in the current tab rather than a new one. W

相关标签:
9条回答
  • 2021-02-06 22:43

    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:

    1. Ask for action
    2. Open it in Adobe Acrobat
    3. 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.

    0 讨论(0)
  • 2021-02-06 22:44

    On Chrome this has proven to work well for me.

    <a href="newsletter_01.pdf" target="_new">Read more</a>
    
    0 讨论(0)
  • 2021-02-06 22:45
    <a href="newsletter_01.pdf" target="_blank">Read more</a>
    

    Target _blank will force the browser to open it in a new window

    0 讨论(0)
提交回复
热议问题