tushar singhal
tushar singhal

Reputation: 53

How to force chrome to download files not opening them?

I am using window.location.href="link.mp4" in a userscript in chrome tampermonkey but rather than starting the download chrome is opening the file and starts playing it. I have a file link in a variable and i also use idm if there's any way to trigger the through idm.

Upvotes: 5

Views: 13758

Answers (3)

Balaji Mitkari
Balaji Mitkari

Reputation: 80

The download attribute specifies that the target will be downloaded when a user clicks on the hyperlink.

<a href="filename.mp4" download>Download File</a>

Try working JSfiddle https://jsfiddle.net/balaji_mitkari/xpu9yrug/

Upvotes: 2

user5574289
user5574289

Reputation:

Did you try download attribute ?

Example Download file when clicking on the link (instead of navigating to the file):

<a href="/images/myw3schoolsimage.jpg" download>

http://www.w3schools.com/tags/att_a_download.asp

Upvotes: 6

Fandango68
Fandango68

Reputation: 4868

Try the HTML5 download attribute

<a href="myfile" download>click to download</a>

This opens a "save as" dialog regardless of file type.

Upvotes: 2

Related Questions