Home > Web Front-end > H5 Tutorial > Detailed explanation of the application of download attribute in HTML5_html5 tutorial skills

Detailed explanation of the application of download attribute in HTML5_html5 tutorial skills

WBOY
Release: 2016-05-16 15:46:18
Original
1756 people have browsed it

In traditional HTML, the download of a certain file is like this:

XML/HTML CodeCopy content to clipboard
  1. <a href="=/files/abc1234564545 .pdf">reporta> 

In HTML 5 browsers, the download attribute can be supported, as follows:

XML/HTML CodeCopy content to clipboard
  1. <a href="=/files/abc1234564545 .pdf" download="abc">report a> 
The advantage of the

download attribute is that when the user downloads a file, what is displayed in the "Save" as file display box in the user's browser
is the
thing displayed in the downloader attribute. , more friendly

In HTML5, the download attribute gives the downloaded file an appropriate name instead of using the native server file name.

XML/HTML CodeCopy content to clipboard
  1. <a href="http: //www.zjgsq.com/demo/1/some-realy-crazy-file-name-389247823879472398.txt" download="test">Click to downloada>

Then when the user clicks the link, the download attribute value appears in the download dialog box, replacing the original messy file name. In this example, the file will be downloaded as test.txt. The download attribute also enables a forced download.

This attribute is very useful where there is file interaction. The file name on the server side needs to be extremely unique (the file name in the above example is very unique, isn't it?), but a bunch of garbled characters does not mean anything to the user. Function, the download attribute defines the file name to be more meaningful to the user. The download attribute is just an enhancement, it's not super cool, but it's useful and very easy to add.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template