点击html按钮,保存网址中提到的内容 [英] save the content mentioned in the url when we click on html button
本文介绍了点击html按钮,保存网址中提到的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
点击html按钮下载后保存网址中提到的内容。请提供怎么办这个。
i不需要在浏览器中显示内容。只是为了保存
问候,
Shefeek
Hi all,
Save the content mentioned in the URL when we click on html button download.Please provide how can do this.
i does'n need to display the content in browser.Just to save
regards,
Shefeek
推荐答案
<a id="downloadLink" href="http://samplepdf.com/sample.pdf">sample pdf</a>
<input type="button" onclick="download()" value="download" />
function download(){
//If the browser understands the content of the link it will display in a new tab else it will download
link =document.createElement('a'); //create link
link.href=document.getElementById('downloadLink').href;
link.target='_blank';
link.click(); //Click the link
delete link;
}
如果可以删除下载按钮,可以避免所有这些步骤。
然后只需以下代码即可完成魔术。 :)
All these steps can be avoided if somehow the download button can be removed.
then just the below code will do the magic. :)
<a id="downloadLink" target="_blank" href="http://samplepdf.com/sample.pdf">sample pdf</a>
这篇关于点击html按钮,保存网址中提到的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文