On the use of a label download pictures video solutions

      function download(url, title) {
        let a = document.createElement('a')
        a.href = url
        a.download = title
        a.click()
      }

If you want to use the parameter titleto rename download, you must follow the same origin policy, if a cross-domain, you press the urlend of the filename naming.
Such as local localhost run the code:

	<a download="test.mp4" href="http://xxx.cn/abc.mp4">test</a>

Download it abc.mp4.

In addition, the titleneed to add their own file suffix, such as .jpg.

Published 59 original articles · won praise 78 · views 20000 +

Guess you like

Origin blog.csdn.net/PrisonersDilemma/article/details/104889177