我想這樣做,我有一個帶有href attr的標籤,它在正常意義上會下載文件,但是我想在更改網頁外觀中的某些信息後進行下載在此代碼:在調用javascript函數後進行下載
這是我有HTML和用戶可以下載文件的HTML。
<li class="imprimir"><h2><a href="javascript:descargarNoticia()" id="descargar" >Descargar Noticia</a></h2></li>
而這裏的JS會改變信息,然後下載文件,但我不能這樣做。
function descargarNoticia(){
$.post("http://www.xxx.com/noticia/datosUsuarios",
function(data){
$("#empresa").show();
$("#email").html(data['email'])
$("#telefono").html(data['telefono'])
$("#direccion").html(data['direccion'])
$("#empresa").html(data['empresa'])
var words = $('#wrapper-960').text().split(' ').length;
var alto=words*0.264583333;
$("#descargar").attr("href","http://pdfcrowd.com/url_to_pdf/?width=500mm&height="+alto+"mm")
}
},'json');
};
謝謝。
'但我不能這樣做。「你是什麼意思?你有錯誤嗎? – 2013-03-13 15:01:34
Noo,它的變化都沒有下載文件(該文件是實際頁面的pdf) – 2013-03-13 15:06:36