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

This article will show you how JavaScript garbage collection works

Table of contents 1. Overview 2. Memory Managemen...

Easyswoole one-click installation script and pagoda installation error

Frequently asked questions When you are new to ea...

A brief discussion on the semantics of HTML and some simple optimizations

1. What is semanticization? Explanation of Bing D...

Limit input type (multiple methods)

1. Only Chinese characters can be input and pasted...

Introduction and analysis of three Binlog formats in MySQL

one. Mysql Binlog format introduction Mysql binlo...

Implementation of css transform page turning animation record

Page turning problem scenario B and C are on the ...

Detailed explanation of html-webpack-plugin usage

Recently, I used html-webapck-plugin plug-in for ...

Solution to the problem of session failure caused by nginx reverse proxy

A colleague asked for help: the login to the back...

Detailed explanation of the concept, principle and usage of MySQL triggers

This article uses examples to explain the concept...

Detailed explanation of MYSQL large-scale write problem optimization

Abstract: When people talk about MySQL performanc...

How to prevent website content from being included in search engines

Usually the goal of building a website is to have...

CSS sets the list style and creates the navigation menu implementation code

1. Set the list symbol list-style-type: attribute...

Solve the problem after adding --subnet to Docker network Create

After adding –subnet to Docker network Create, us...