0

I hope you can help.

I am using node, express, router and ejs.

A use case is: I am on http://localhost:8080/save/page1 and in order to save the page I need to right-click and save-as. Ideally I want the user to be able to initiate the save-as modal by clicking on a button on the page.

Is there a way to initiate the right-click > save-as modal?

I have tried Googling with little success. I'm probably Googling all wrong.

Thanks for all your help. It's much appreciated.
Moe

Moe-Joe
  • 1,012
  • 3
  • 15
  • 27
  • Where are you trying to save the file? On your server hard drive? On the browser user's hard drive? `fs.writeFile()` can only run on the server, not in the user's browser. – jfriend00 Jan 31 '18 at 05:57
  • Also, are you aware that fetching a page with `request()` gets only the raw HTML. It does not get anything that might be dynamically added to the page with Javascript in the page. It does not get images or scripts for that page. You would have to parse the page, find all those other resources and then fetch them individually (just like the browser does). If you wanted a fully formed page that includes additions to the page from Javscript in the page, then you need a headless browser that can actually present a DOM interface and run the Javscript in the page to let it do its page mods. – jfriend00 Jan 31 '18 at 05:59
  • @jfriend00 I was not aware of that limitation. I guess I am looking to fire the `save-as` modal. I will edit my post to reflect this. – Moe-Joe Jan 31 '18 at 06:11
  • @jfriend00 I've updated the question to better reflect the functionality I would ideal like to implement. Thanks for pointing those caveats out. – Moe-Joe Jan 31 '18 at 06:16
  • See a "download" button in any file sharing web site. That's the best you can do. User clicks the download button and a File/Save As dialog pops up. – jfriend00 Jan 31 '18 at 06:53
  • See [Starting file download with Javascript](http://thezedienblog.blogspot.com/2013/05/starting-file-download-with-javascript.html) – jfriend00 Jan 31 '18 at 07:11
  • See [Download a file from nodejs server](https://stackoverflow.com/questions/7288814/download-a-file-from-nodejs-server-using-express) – jfriend00 Jan 31 '18 at 07:12

0 Answers0