Click here to Skip to main content
16,004,653 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Comments
Thomas ktg 18-Sep-13 9:50am    
You want to use javascript to save the content from the url or JScript?
ZurdoDev 18-Sep-13 10:34am    
What?

1 solution

HTML
<a id="downloadLink" href="http://samplepdf.com/sample.pdf">sample pdf</a>
<input type="button" onclick="download()" value="download" />

JavaScript
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. :)

HTML
<a id="downloadLink" target="_blank" href="http://samplepdf.com/sample.pdf">sample pdf</a>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900