<html><head>
<title>Self-Downloading Page</title>
</head>
<body>
<textarea id="textArea" rows="10" cols="50">Try writing here then click the button.</textarea><br>
<button onclick="downloadPage()">Download This Page</button>
<script>
function downloadPage() {
document.getElementById('textArea').textContent = document.getElementById('textArea').value;
const html = document.documentElement.outerHTML;
console.log(html);
const blob = new Blob([html], { type: 'text/html' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = new Date().toISOString() + '.html';
a.click();
URL.revokeObjectURL(url);
}
</script>
</body></html>
a page that downloads itself
Published inenglish
Be First to Comment