最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to Download video tag using JS? - Stack Overflow

programmeradmin10浏览0评论

I have a link that I want to download the video from.

<video name="media">
 <source src="" type="video/mp4">
</video>

I want to be able to download the vid to the user storage using javascript.

I have a link that I want to download the video from.

<video name="media">
 <source src="https://foo.bar" type="video/mp4">
</video>

I want to be able to download the vid to the user storage using javascript.

Share Improve this question edited May 17, 2019 at 15:37 Pingo asked May 17, 2019 at 15:30 PingoPingo 5332 gold badges5 silver badges8 bronze badges 9
  • Are you saying you want to download the video from someone else's website in order to play it, or that you want to download it to the user's computer? – Caleb H. Commented May 17, 2019 at 15:32
  • to the user's computer – Pingo Commented May 17, 2019 at 15:32
  • This might help you: stackoverflow.com/questions/17311645/… – Caleb H. Commented May 17, 2019 at 15:34
  • Why local storage? stackoverflow.com/questions/46403706/… – Train Commented May 17, 2019 at 15:35
  • Or are you wanting to store the video in localStorage? – Caleb H. Commented May 17, 2019 at 15:36
 |  Show 4 more comments

2 Answers 2

Reset to default 7

Just add an anchor tag with the same link and a download attribute:

<a href="https://foo.bar" download>
    Download Me!
</a>

Since you have the link, you can trigger it manually.

var a = $("<a>")
    .attr("href", "LINK HERE")
    .attr("download", "vid.mp4")
    .appendTo("body");

a[0].click();

a.remove();
发布评论

评论列表(0)

  1. 暂无评论