0

I have a informative web page in my spring based web application which need to be saved as html/downloaded. My requirement is to save/ download this opened webpage on click of a button on same page.

I used below code in javascript.

document.execCommand("SaveAs",true,"C:\Saved Content.html");

But this is only working in IE and not in other browsers.

Kindly help on this.

Harjot
  • 77
  • 2
  • 13

1 Answers1

0

Simply no. JavaScript/Jquery is restricted to perform such operations due to security reasons.

The best way to achieve this, would be, to send a request to the server that would write the new file on the server.

Then from javascript perform a POST request to the server page passing the data you want to write to the new file.

Ankur Singhal
  • 26,012
  • 16
  • 82
  • 116
  • But i dont want to post again to get static content I already have. – Harjot Nov 17 '14 at 12:50
  • So whatever response you are getting from server in the first place, write it into html file and make it downloadable, or also look for HTML5, there might be a possibility of getting something. – Ankur Singhal Nov 17 '14 at 12:52