如提 突然遇到要抓檔案但都會多跳出東西視窗的奇怪現象 不知道怎模˙改@@
<button id="download" type="button" class="btn btn-success" onclick="download()"><i class="fa fa-download"></i> 媒體申報轉帳檔下載</button>
download method怎麼寫呢?
(因為要抓欄位的變數 所以必須用js)
function download() {
Type = $('#SalaryTypeCombo').dxSelectBox('option').value;
Year = $('#SalaryYear').val();
Month = $('#SalaryMonth').val();
window.open("/SAM07/SAM0703/Download?Type=" + Type + "&Year=" + Year + "&Month=" + Month, '_blank');
下面註解的都是不適合用來做下載連結的 因為要使用的方法必須支援跳出新視窗的功能才適用(否則會出現視窗導致問題)
//window.location.href("/SAM07/SAM0703/Download?Type=" + Type + "&Year=" + Year + "&Month=" + Month, '_blank')
//window.location.assign("/SAM07/SAM0703/Download?Type=" + Type + "&Year=" + Year + "&Month=" + Month);
//popUpEdit('editPopUp', '@Url.Action("Download")?Type=' + Type + '&Year=' + Year + '&Month=' + Month, "檔案下載選擇")
}
結論 window.open(下載連結, '_blank');
可以拿來用 有下載檔案的action 使用喲!
歡迎高手低手來看看 指教指教 切磋切磋 教學香腸