2
Contributors
5
Replies
6
Views
5 Years
Discussion Span
Last Post by adam.adamski.96155
0

If the browser is navigating to a pdf file, it will probably try to open it with the browser plug-in unless the browser's own config tells it to pass the file to the system default application. If you offer the browser the file for download, I imagine the user will get the opportunity to open the file with their system default program or do whatever they want with it.

0
  1. I did a search on google for "offer file for download".
  2. I checked the third result
  3. I found the answer:

    content = "abc123";
    document.location = "data:text/octet-stream," + encodeURIComponent(content);
    
  4. I tested it:

        function download(){
        content = "image.jpg.jpg";
        document.location = "data:text/octet-stream," + encodeURIComponent(content);
        }
    

and...

<a href="javascript:;" onclick="download(); return false;">click</a>

...it worked, offering me the file for download.

[edited to fix code format.]

Edited by adam.adamski.96155

0

I tried it and it just shows me an empty screen with the path as a text.. horrible

the url is changing to 'data:text/octet-stream,..%2Ftmp%2Ffile.pdf' which doesn't look right to me..

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.