Inbal
Inbal

Reputation: 929

How to display download file popup (not a new window)?

I try to display "save as" popup on IE using javascript (jquery is ok too). The expected result is: enter image description here

I use this code:

window.open("some url on my server", "_self");

and I get: enter image description here

How can I make it look like in the first picture? as a popup at the bottom of the page, and not modal like I get..

Upvotes: 0

Views: 5225

Answers (1)

BenM
BenM

Reputation: 53246

You can't do this with JavaScript or jQuery. You need to set the HTTP headers of the request as follows:

header('Content-disposition: attachment; filename=excel1.xlsx');
header('Content-type: application/vnd.ms-excel');

The above is a PHP example. Telling the browser to handle the request as an octet stream will prompt the user with the Save As... dialogue.

Upvotes: 1

Related Questions