One of the simplest ways we might think of is to a
link a picture directly to a button tag, like this:
<a href= "large.jpg" > Downloads </a>
However, although the idea is good, the actual effect is not what we want, because the browser can directly browse the picture, so we click the "Download" link below, and is not to download the image, but in a new window to browse the image directly.
For example, we want to click on the "Download" link to download the image instead of browsing, adding a download
property directly to:
<a href= "large.jpg" download> download </a>
Results in Chrome (Firefox browser is invalid because of cross-domain restrictions):
Change to <a href= "Index_logo.gif" download= "_5332_.gif" > Download </a>
Whether to support monitoring of download properties
To monitor whether the current browser supports download
attributes, a single line of JS code is available, as follows:
var issupportdownload = ' Download ' in Document.createelement (' a ');
Browser Download file