Html download function

Source: Internet
Author: User

Html download function

The new project has come to an end. The first time the integration of frontend and backend separation is completed, there are naturally many pitfalls.

Let's talk about one of the pitfalls we encountered on the first day.

-- About download...

In the past, we all liked to use the <a> </a> label. At first, I used the tag and href attribute to simulate the download function at the image address. It turns out that you click this ghost thing to open a new image, not to download it.

Then I read an article and opened the door to the new world of my baby.

Download attributes

<A> the tag must have the href attribute. The browser will automatically detect the correct file extension and add it to the file (. img,. pdf,. txt,. html, and so on ).

For example:

<A href = "ccc.jpg" download>

You can also customize the downloaded file name

<A href = "ccc.jpg" download = "wageSoCute.jpg">

However, this method also has great limitations.

One is its compatibility, based on the data provided by W3C.

 

 

In this case, it seems that this attribute is generally practical for the moment.

Another pitfall is that I haven't stepped on yet, that is, cross-domain issues. When I stepped on, I updated it ..

To sum up, this download is a good thing, but it seems that the support is not good. I don't know what his future development will be like. After all, it is still a new attribute of the tag, let's take a look. Now, at least we know that there is such a thing.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.