简体   繁体   中英

How to download a file without the “Leave the Page” dialog or any other prompt?

In Internet Explorer 10; When i try to download a file; i get following dialog box: 在此输入图像描述

Is there someway in Jquery or HTML with which this box does not get appear when user tries to download a file in application?

Update : Also could not user target blank as flashing of new tab should not be there(customer requirements). As asked for code, it is simple link:

<a href="www.something.com/something/something.pdf" >

jquery.fileDownload.js will help you in this.

apply file path to

function downloadPDF(thisobj) {        
    $.fileDownload($(thisobj).attr("href"));
}

Call this funciton on

<a href="www.something.com/something/something.pdf" onclick="downloadPDF(this)"> 

I'd suggest you look into HTML5's download attribute .

Excerpt from the site:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM