在我的html文件中,我想要點擊圖像鏈接時,它開始下載圖像到本地文件夾。通常要下載一個鏈接,我們必須右鍵單擊然後選擇另存爲。Html:如何下載鏈接點擊,而不是右鍵單擊並保存爲
我試過如下:
var href = document.createElement("a");
href.setAttribute("href", url1);
href.appendChild(document.createTextNode("Image Download"));
href.setAttribute("download", "test.jpg");
contentDiv.appendChild(href);
但它仍然沒有工作。我點擊,圖像瀏覽器
'download'我在firefox中試過這個。它沒有工作 –
'href =「insert/path /(你希望用戶保存到哪裏)」'這是什麼意思。我的圖像href是'https://farm8.staticflickr.com/7555/29856053076_43 ccee f1b6_o.jpg' –
謝謝你的幫助。我迫切需要一些工作解決方案。你能否澄清我的意見 –