-1

The below javascript will open the url in a new tab. I want to save contents of the loaded webpage to a text file. Also after saving I wanted to close the tab. How can i do in java script

var newtab = window.open('https://webpage.com');
Suresh
  • 1,081
  • 4
  • 21
  • 44

1 Answers1

1

You should probably consider using a different programming language, and not JavaScript for what you are trying to accomplish.

Read this StackOverflow article regarding writing files with javascript: Is it possible to write data to file using only JavaScript?

There are security reasons why JavaScript does not allow the method of saving files locally on machines for the most part - the primary reason is because that it runs on all browsers and would be a huge security flaw (ie: think of drive-by scripts that could just throw any file on your computer).

Hope this helps.

escapesequence
  • 202
  • 4
  • 12