Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download current html file

How is it possible, to let the user download the current html page? The webpage loads the text using ajax, so my code doesn't works, because it downloads the original state of the page:

<a href="URL_OF_THIS_PAGE" download="page.html">Download</a>
like image 793
Iter Ator Avatar asked Oct 06 '14 15:10

Iter Ator


1 Answers

<a onclick="this.href='data:text/html;charset=UTF-8,'+encodeURIComponent(document.documentElement.outerHTML)" href="#" download="page.html">Download</a>
like image 57
lujjjh Avatar answered Oct 07 '22 22:10

lujjjh