Force to Open "Save As..." Popup Open At Text Link Click For Pdf in Html

How to force open Save as... dialog on left click for downloading file from remote server

You really can't force a save-as dialog. Sorry.

Alternative approach

When they click a link you can use javascript to show a prompt for a better name. When they have filled in the name you can use the html5 <a download="name"> attribute to provide a link that downloads with the better name.

(HTML) Download a PDF file instead of opening them in browser when clicked

There is now the HTML 5 download attribute that can handle this.

I agree, and think Sarim's answer is good (it probably should be the chosen answer if the OP ever returns). However, this answer is still the reliable way to handle it (as Yiğit Yener's answer points out and--oddly--people agree with). While the download attribute has gained support, it's still spotty:

http://caniuse.com/#feat=download

Force a link to open a Save link as dialog

If I understood correctly and without any plugins, I think it is almost impossible. The only way you can do that would require you to verify the browser and for some browser like Chrome (due the spec http://dev.w3.org/2009/dap/file-system/file-dir-sys.html ) you can do that.

Links on a webpage to either view or download a PDF

How PDFs are displayed are based on the user's browser version and configuration. For example Chrome includes a PDF viewer by default, but the user has the ability to change the behavior of the plug-in ( automatically open PDFs, disable, ask the user).

One way to do this is to set the ContentType and Content-Disposition so the browser will know how to handle the request. For example in ASP.NET you would do it like this:

Response.ContentType = "application/pdf";

Response.AddHeader("Content-Disposition", "attachment;filename=filename.pdf");

Disclosure: I hijacked this code from this article

Let me know if this helps.

How can I set the file name for a download link?

You can suggest a filename for the browser to use when saving the file in the value of the download attribute.

<a href="https://-----/test1.pdf" download="test2.pdf">download </a>


Related Topics



Leave a reply



Submit