How to open downloaded file in new tab using javascript

This is what has been happening for a while if you have “Open in Firefox” selected as your PDF handling preference (that is the default setting):

(A) If the server accurately identified the PDF using “Content-Type: application/pdf” and did NOT send the “Content-Disposition: attachment” header to force downloading:

Firefox saves the file in the web content cache and opens the PDF with the web address showing in the address bar.

(B) If the server accurately identified the PDF using “Content-Type: application/pdf” and DID send the “Content-Disposition: attachment” header to force downloading:

Firefox saves the file in the folder you selected next to “Save files to:” on the Settings page and opens it in a new tab with the local path (file:/// ) showing in the address bar.

Firefox 102 added a preference that allows switching from the “Save files to:” folder to the Temp folder.

© Other situations…

Firefox sometimes takes the .pdf extension at face value when sites try to sneak it past using inaccurate Content-Type values (such as “Content-Type: application/force-download”). In that case, it may follow behavior (B). Otherwise, it may auto-save the file.

Support » Plugin: Download Manager » Force download or open in new tab

Force download or open in new tab

  • mstudioIL

    (@mstudioil)


    1 year, 11 months ago

    My site has PDF to view and they open in new tab, when I open download from the files zone, the PDF is open in the same tab of the download page.
    how I can force download or open the file in new tab?

Viewing 3 replies - 1 through 3 (of 3 total)

  • Plugin Support Nayeem Hyder

    (@nriddhi)

    you can follow the link below documentation,

    https://www.wpdownloadmanager.com/doc/template-files/
    by default, you are using link-template-default.php for link template and page-template-default.php for the page template. As documentation, you have to copy the file in the theme directory naming a folder called download-manager, then paste it in tpls>page-templates for page template or tpls>link-templates for link template. And you have to replace [download_link] with <a href="[download_url]" class="btn btn-primary" target=_blank>[link_label]</a> in related php file.

    Thanks.

    Thread Starter mstudioIL

    (@mstudioil)

    Can I set you private message with user and password to check it?
    I think I doing something wrong
    Is the dir is themes/child-theme/download-mamager/
    or themes/child-theme/download-mamager/tpls ?

    missmikado

    (@missmikado)

    How can I force download of images?
    I tried it with your documentation and added
    <a href="[download_url]" download>[link_label]</a> and/or <a download="[download_url]">[link_label]</a>

    Both not successful. I don’t think it even recognizes, that it should use the files in child-theme/download-manager.
    It still opens the images in the browser. I made some other changes in the php and they are not showing up, too.

    • This reply was modified 1 year, 10 months ago by missmikado.
    • This reply was modified 1 year, 10 months ago by missmikado.
    • This reply was modified 1 year, 10 months ago by missmikado.

Viewing 3 replies - 1 through 3 (of 3 total)

  • The topic ‘Force download or open in new tab’ is closed to new replies.

How to open a file in new tab using JavaScript?

To open a new tab, we have to use _blank in the second parameter of the window. open() method..
The return value of window. open() is a reference to the newly created window or tab or null if it failed..
Do not add a third parameter to it as it will result in the opening of a new window rather than a tab..

How do I open a downloaded file in a new tab?

1) To make a link open in a new tab, add target="_top" to the href . 2) You should respond to an event in order for the html to be rendered.

How to open PDF file in new tab in JavaScript?

There several ways to download or view the PDF. And in order to open it to new tab in javascript, please add this code. window. open("Here Download PDF url", '_blank');

How do I open a PDF in a new tab or window instead of downloading HTML?

You can make the link open in a new window by adding target="_blank" .