2

Is possible to show the "Save page as" dialog via Javascript?

I think that there must be such a browser function, at least for Chrome/Chromium.

If not, what are the alternatives?

When I say "Save page as" dialog I mean how to make the following window appear via Javascript (when pressing a button, for example).

Ionică Bizău
  • 109,027
  • 88
  • 289
  • 474

1 Answers1

6

Via JavaScript Strictly, No.

But here are two alternatives, 1 client side and 1 server side.

Force Download via HTM5 link.

Now the HTML5 spec defines a very useful download attribute on hyperlinks that basically allows to force download behavior on client-side, regardless of what comes in Content-Type and Content-Disposition from the server.

Fiddled Here: http://jsfiddle.net/qmwxt/

<a href="URL" download> Download your Question</a>

Read more here: https://stackoverflow.com/a/15970140/144665

Set Content-Disposition in the header.

Or if you have server side control set Content-Disposition in the header which forces the save dialog.

Read more here: How to encode the filename parameter of Content-Disposition header in HTTP?

Community
  • 1
  • 1
iambriansreed
  • 21,935
  • 6
  • 63
  • 79