0

Instead of creating an additional text file and provide a link to it, can one embed some texts into an HTML file and provide a link to download it? The solution should work for a static website.

xuhdev
  • 8,018
  • 2
  • 41
  • 69

2 Answers2

1

You should be able to base64 encode the file in the link, but you may want to do some cross-browser testing.

See Create a file in memory for user to download, not through server

Community
  • 1
  • 1
Ted Whitehead
  • 1,731
  • 10
  • 18
0

If I understand correctly, you have a static website and you want to be able to create a link to a HTML page that should be downloaded instead of "viewed" in the browser.

The only way I can think of to solve this is to use the HTML 5 download attribute, like this:

<a href="somepage.html" download="somepage.html">Download</a>
Andre Pena
  • 56,650
  • 48
  • 196
  • 243
  • The point is to embed some text to the html file so that there is no need to provide an additional file on the server for downloading. – xuhdev Feb 11 '16 at 01:04