Jangkar unduh Properti
Contoh
Menampilkan nilai atribut unduhan tautan:
var x = document.getElementById("myAnchor").download;
Definisi dan Penggunaan
Properti unduhan menetapkan atau mengembalikan nilai atribut unduhan tautan.
Atribut download menentukan bahwa target akan didownload ketika pengguna mengklik hyperlink.
Catatan: Atribut download baru untuk elemen <a> di HTML5.
Dukungan Peramban
Angka-angka dalam tabel menentukan versi browser pertama yang sepenuhnya mendukung properti.
Property | |||||
---|---|---|---|---|---|
download | Yes | 12.0 | Yes | Not supported | 15.0 |
Sintaksis
Kembalikan properti unduhan:
anchorObject.download
Setel properti unduhan:
anchorObject.download = filename
Nilai properti
Value | Description |
---|---|
filename | Specifies some text to be used as the filename (no need to specify the file extension - the browser will automatically detect the correct file extension and add it to the file, e.g. .img, .pdf. .txt, .html, etc.). If omitted, the original filename is used. |
Detail Teknis
Nilai Kembali: | Sebuah String, mewakili nama file yang diunduh |
---|
Lebih Banyak Contoh
Contoh
Ubah nilai atribut unduhan tautan:
document.getElementById("myAnchor").download = "newValue";
Halaman Terkait
Referensi HTML: Atribut unduhan <a> HTML
Objek Jangkar