Detailed explanation of html download function

Detailed explanation of html download function

The new project has basically come to an end. It was the first time I completed the integration of front-end and back-end separation, and naturally I encountered many pitfalls.

Let’s talk about one of the pitfalls I encountered on the first day.

——About downloading issues. . .

In the past, everyone liked to use the <a></a> tag. At the beginning, I also used the a tag and placed the href attribute in the address of the picture to simulate the download function. It turns out that this damn thing, when you click on it, it directly opens a new picture, it doesn't mean downloading.

Then, I read an article, which opened the door to a new world for me.

download attribute

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

For example, let's take an example:

<a href="ccc.jpg" download>

You can also customize the downloaded file name.

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

But in fact, this method also has great limitations.

One is its compatibility, according to data provided by W3C.

It seems that the practicality of this attribute is actually average for the time being.

There is another pitfall that I haven't encountered yet, which is the cross-domain issue. I will update it after I encounter it. .

In conclusion, this download is a good thing, but it seems that the support is not very good . I wonder how it will develop in the future. After all, it is still a new attribute of the a tag. Let's wait and see. At least we know that there is such a thing.

The above detailed explanation of the html download function is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

Original URL: http://www.cnblogs.com/w-age666/archive/2016/05/04/5458342.html

<<:  MySQL transaction isolation level details

>>:  Drop-down menu implemented by HTML+CSS3+JS

Recommend

MySQL-8.0.26 Configuration Graphics Tutorial

Preface: Recently, the company project changed th...

Analysis on the problem of data loss caused by forced refresh of vuex

vuex-persistedstate Core principle: store all vue...

JavaScript function call classic example code

Table of contents JavaScript function call classi...

Use Nginx to build a streaming media server to realize live broadcast function

Written in front In recent years, the live stream...

Get / delete method to pass array parameters in Vue

When the front-end and back-end interact, sometim...

Detailed explanation of how to use the Vue license plate input component

A simple license plate input component (vue) for ...

mysql5.5.28 installation tutorial is super detailed!

mysql5.5.28 installation tutorial for your refere...

Steps to create a Vite project

Table of contents Preface What does yarn create d...

Pure CSS header fixed implementation code

There are two main reasons why it is difficult to...

Example code for evenly distributing elements using css3 flex layout

This article mainly introduces how to evenly dist...

How to uninstall MySQL cleanly (tested and effective)

How to uninstall Mysql perfectly? Follow the step...

The magic of tr command in counting the frequency of English words

We are all familiar with the tr command, which ca...

MySQL 5.7 mysql command line client usage command details

MySQL 5.7 MySQL command line client using command...