Shaun Shaun - 1 year ago 113
jQuery Question

Force download through js or query

Is it possible to force a download through JS or Javascript i-e the web page should not open the file in new tab in the browser but to pop up to let the user to choose eith "save as" or open with ???

Answer Source

You can not force that behavior from JavaScript, the HTTP Headers need to be set on the server side:


The way you can solve the problem is to let your AJAX method redirect the user to the URL of the PDF:


(The above HTTP headers must be set for the PDF)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download