download attribute not working anymore

2020-02-14 06:45发布

问题:

I used to use this code to download resources:

<a href='http://example.com' download> Download </a>

Where example.com is another website (cross origin).

But this is not working now , I tried Chrome - Opera - Mozilla and even Internet Explorer , But it's not working.

回答1:

See https://caniuse.com/#search=download ("Known Issues" Tab) where it says:

Firefox only supports same-origin download links.

Chrome 65 and above only supports same-origin download links.

IE does not support the download-attribute at all



回答2:

I figured out a workaround for downloading images cross-origin. You may be able to modify this to work with other media types. Hope this helps Force browser to download image files on click



回答3:

All major browsers have implemented this as a security guard for the user. In addition it is stated in the HTML spec (link to chrome feature)