function saveTextAsFile() {
var title = document.getElementById('title').value;
if (title == "") {alert('Type your title!'); return false;}
// Get the textarea element by its ID
var textarea = document.getElementById('output');
// Get the text from the textarea
var textToSave = textarea.value;
// Create a new Blob object with the text content
var blob = new Blob([textToSave], { type: 'text/plain' });
// Create a temporary <a> element
var link = document.createElement('a');
// Set the href attribute of the <a> element to the URL of the blob
link.href = URL.createObjectURL(blob);
// Set the download attribute to specify the default file name
link.download = ''+title+'.html';
// Programmatically click the link to trigger the download
link.click();
}
var title = document.getElementById('title').value;
if (title == "") {alert('Type your title!'); return false;}
// Get the textarea element by its ID
var textarea = document.getElementById('output');
// Get the text from the textarea
var textToSave = textarea.value;
// Create a new Blob object with the text content
var blob = new Blob([textToSave], { type: 'text/plain' });
// Create a temporary <a> element
var link = document.createElement('a');
// Set the href attribute of the <a> element to the URL of the blob
link.href = URL.createObjectURL(blob);
// Set the download attribute to specify the default file name
link.download = ''+title+'.html';
// Programmatically click the link to trigger the download
link.click();
}
0 Responses to Save for Download Page Generator by Privateloader 2 Script