jquery.fileDownload.js可以帮助你实现这个目标。
将文件路径应用于:
"function downloadPDF(thisobj) {
$.fileDownload($(thisobj).attr("href"));
}
在此调用该函数
<a href="www.something.com/something/something.pdf" onclick="downloadPDF(this)">
Place the download attribute on a link...
<!-- will download as "expenses.pdf" --> <a href="/files/adlafjlxjewfasd89asd8f.pdf" download="expenses.pdf">Download Your Expense Report</a>
...and when the user clicks the link, the download attribute appears in the save dialog instead of the garbled mess that was there before. In this case, the file will be downloaded as expenses.pdf. The download attribute also triggers a force download, something that I used to do on the server side with PHP.
_blank
窗口中打开下载链接。 - Parth Trivedi<a href="www.something.com/something/something.pdf" target="_blank">
- Parth Trivedi