Download file on left-click without viewing

  Newuser549 12:42 12 Aug 03
Locked

Any JavaScript gurus listening?

I want the user to be able to download a pdf file by simply left-clicking a link rather than the more involved right click and "save target as".

Is there a way of using a JavaScript onclick function to modify the default left click behaviour of viewing the file?

Thanks.

  Jester2K II 16:38 12 Aug 03

Put the file in a ZIP file and left click will download...

  User-312386 00:49 16 Aug 03

<p><a target="_blank" href="click here">

  User-312386 00:51 16 Aug 03

ignore my comments

  Forum Editor 08:41 16 Aug 03

is not to right click and 'save target as'.

The link to the PDF will automatically download the file to the visitor's machine on a left click - provided he/she has the Acrobat reader installed. The normal procedure would then be for the person to save the file on their drive in the normal way - if he/she wanted to.

It doesn't matter what you do, the file can only be opened in the PDF reader anyway, and I can see no point in trying to make it more complex than that, and you certainly don't need to involve Java script. Just put the PDF file on the server (it's a good idea to keep it in a separate PDF directory) and then hyperlink to it in your HTML page in the normal way. The visitor's browser will do the rest.

It helps to provide a separate link to the Adobe site as well - so that people who may not have the Acrobat reader can download it before attempting to retrieve your file. Use a text link:

"You will need to have Adobe Acrobat reader installed on your machine before you can view this file. If you don't have the reader you can download the latest version HERE"

Make "HERE" a hyperlink to Adobe.com

  Pesala 09:18 16 Aug 03

I had problems like this before. When users left-clicked on a large PDF file, they just got a blank white page while IE did its stuff. If they waited five minutes or so for the large file to download it viewed OK via the browser plugin.

I put a note on my site to "Right-click and Save target as..." to overcome this problem: click here

However, since I update my own system to Adobe Reader 6.0, I get an error message as above. I expect that when I installed the reader I chose not to open PDFs in the browser as that is the way I prefer to work.

Madboy's solution is a good way around it but it involves the extra step of unzipping the file.

Opera is more configurable than IE.

• Download to default directory without asking

• Open in browser

• Open in Adobe Reader (default application, or another application)

• Show dialogue box

These can be configured differently on left-click for any file type - PDF MP3 ZIP DOC etc.

  Newuser549 22:14 16 Aug 03

Good description of the general case - thanks. That is more or less what I do for most of my downloads, but there are times when the user won't be viewing the document in the browser there and then, but is saving it for later (eg a very large reference document).

What I was looking for was a method to immediately invoke download to disk on left click rather than view in browser, so it would bring up the normal download box straight away rather than wait for a long time while the download into the browser completes. Recognise that the overall process won't be any quicker, but feedback to the user is better.

This thread is now locked and can not be replied to.

What is Amazon Go and will it come to the UK? The store without checkouts or queues

1995-2015: How technology has changed the world in 20 years

Hands-on with the Star Wars fighting drones you can fly yourself

15 macOS Sierra tips | How to use macOS Sierra: Secret tricks and best new features in Apple's new…