How to get a download box for the following code. i.e., when user clicks on download hyperlink the download window should appear irrespective of the browser type. I have tried the following:
<a href="javascript:void(0);" onclick="download_tagged_file('{{cnt.id}}');">Download</a><
function download_tagged_file(cntid)
{
var snddata = {};
snddata["cntid"] = cntid;
$.post("/tagging/download_tagged_file/", snddata,
function callbackHandler(data, textstatus)
{
if (data.status == 1)
{
var url = data.filename;
url = "http://127.0.0.1:8000" + url
//var htm = '<iframe style="display: none;" id="if1" src="'+url+'"></iframe>';
//alert(url);
window.open(url, 'download_window', 'directories=0,status=0,scrollbars=0,resizeable=0,width=1,height=1,top=0,left=0');
window.focus();
}
I don’t really get what youre trying to do, whats wrong with:Update:
you need to control the content disposition server-side. The above html is what you need, but your server needs to send this header when serving the file: