Answers for "javascript download current html page"

0

javascript download current html page

// in the current page, download the html source
var hiddenElement = document.createElement('a');
hiddenElement.href = 'data:attachment/text,' + encodeURI(document.documentElement.outerHTML);
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.txt';
hiddenElement.click();
Posted by: Guest on December-29-2020
0

how to set a var in js to be a download

var textToSave = 'this is a test';

var hiddenElement = document.createElement('a');

hiddenElement.href = 'data:attachment/text,' + encodeURI(textToSave);
hiddenElement.target = '_blank';
hiddenElement.download = 'myFile.txt';
hiddenElement.click();
Posted by: Guest on March-25-2020

Code answers related to "javascript download current html page"

Code answers related to "Javascript"

Browse Popular Code Answers by Language