I have a website which hosts large PDF documents, as well as some other file formats.
How can I open up a download-dialog box in javascript so that the user can save the document to their computer?
PDF always needs download (even for iframe / embed /object ) so do not use those as its then potential double overload on server, once to downlink and show then potentially a second time by the scripting (However if user selects the "save download as" button in viewer the download should be just once)
The answer is display a small image or icon to show the download content, then back that up with
<Img src="cover.png">
something like this:-
<a href="https://africau.edu/images/default/sample.pdf" download="A Sample.pdf"><img src="https://www.freeiconspng.com/uploads/download-pdf-icon-png-icon-29.png" width="128" height="128"><a><br>right click icon to chose download options
note clicking the icon may show a blank page based on browser security, that is normal, hence the suggestion the user uses their discretion.
Related
Im new to JS. I am currently trying to implement a link/button that will download an image to the user's computer. The image will not be from the same url but a completely different one: for example, some random URL like this one. What I tried doing is implementing the button like this:
<a href="https://cdn.akc.org/Marketplace/Breeds/Rottweiler_SERP.jpg" download=""</a>
But when ever i press the link, I am taken to another page showing the image but the download is not being initiated. Is there any way I can get the image to be downloaded once the user clicks the image/link?
I am using IE 11 for web development. Now in javascript, I do window.msSaveOrOpenBlob(fileBlob), a pop up shows on the button of the page with save and open option.
Now what I want to achieve is that perform click event on open so the file will be open automatically(without user click open).
Here is the case:
User click a link, it should open the associated file with whatever file reader that can open the file. PDF, will be adobe reader, word document will be opened in microsoft word.
Things still works when I click the open button from pop up. I just want to skip this manual click and do it in the code.
I've seen some webpage does this, but can't figure out myself. Need some help.
As far as I know, we can't control the "open or save" prompt using JavaScript. It is the browser behavior.
As a workaround, to the pdf file, I suggest you could try to use the pdf.js plugin to display the pdf file. To the Office documents, you could check the following article to use the Office Web Viewer to view the document.
Office Web Viewer: View Office documents in a browser
Besides, here is an article about displaying (Show) Word, Excel, PowerPoint (PPT) and PDF files in browser web page in ASP.Net, you can also refer to it.
I want to open "Save as..." dialog on left click on link for file downloading from not my servers. Main idea - create link for downloading image, image getting with bad name. I want to force edit it in browser dialog, before user download it.
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.
I have some customized PNG images in HTML pages. I want to Hyperlink these images in a way that when clicked they should download as a .MSG file. That is, it should give the option of opening in an Outlook email body straight away.
I'm not sure how to go about this. Whether I need to convert the PNG images to MSG files somehow.
Any advice would be appreciated.
As a background, the HTML files are currently heavy on JavaScript that is used to customize the images by the user. The customized images can be saved as a PNG image by the user by right clicking the image and saving. I have avoided 'download' attribute because of its inconsistent support across browsers.
What I want is for the user to be able to load the final customized image to his/her email straight away.
Outlook will not let you run any scripts of navigate in the HTML body of an email. All navigation will be redirected to an external browser.
I have a PDF embedded in a web page using the following code:
<object id="pdfviewer" data='test_full.pdf#page=1&toolbar=0&statusbar=0&messages=0&navpanes=0'
type='application/pdf'
width='500px'
height='350px'>
The PDF itself is set to open in full screen mode which shows no controls. The user can advance the slides by clicking on the view.
What I'd like to have is some way to trigger that click so that I can advance 2 similar PDF:s side-by-side (one for the actual slideshow and one for the speaker notes). Is this possible to do in javascript and/or jQuery? I have tried using the click()-method but it doesn't get through to the embedded PDF.
Update: Can't find any info on it, so I guess I'm out of luck and have to try a workaround. Am currently juggling 3 embeds of the same pdf (current page, next page and previous page), hiding and showing them and loading more pages as the user clicks around.
I doubt it. Allowing web page scripts to pass input events to the PDF viewer could be a security risk (since the viewer generally has access to system file dialogues via things like Save As).