8

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>
Iter Ator
  • 7,047
  • 16
  • 57
  • 138

1 Answers1

17
<a onclick="this.href='data:text/html;charset=UTF-8,'+encodeURIComponent(document.documentElement.outerHTML)" href="#" download="page.html">Download</a>
lujjjh
  • 453
  • 3
  • 9
  • 6
    can u pls describe what u did? And also what command should i write on the browser console to download the current page. pls rply – sony Feb 27 '16 at 04:22
  • Please note any blobs (i.e. media files like ` – The Red Pea Aug 22 '20 at 21:27