アンカーダウンロードプロパティ
例
リンクのダウンロード属性の値を表示します。
var x = document.getElementById("myAnchor").download;
定義と使用法
downloadプロパティは、リンクのダウンロード属性の値を設定または返します。
download属性は、ユーザーがハイパーリンクをクリックしたときにターゲットがダウンロードされることを指定します。
注:ダウンロード属性は、HTML5の<a>要素の新機能です。
ブラウザのサポート
表の数字は、プロパティを完全にサポートする最初のブラウザバージョンを示しています。
Property | |||||
---|---|---|---|---|---|
download | Yes | 12.0 | Yes | Not supported | 15.0 |
構文
ダウンロードプロパティを返します。
anchorObject.download
ダウンロードプロパティを設定します。
anchorObject.download = filename
プロパティ値
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. |
技術的な詳細
戻り値: | ダウンロードしたファイルの名前を表す文字列 |
---|
その他の例
例
リンクのダウンロード属性の値を変更します。
document.getElementById("myAnchor").download = "newValue";
関連ページ
HTMLリファレンス:HTML <a>ダウンロード属性
❮アンカーオブジェクト