I have created a simple page builder (that can create columns, tabs, buttons, etc) using JavaScript.
Now I want to let the user export a web page that was created with my page builder. I want to put a "download" button in toolbar and when the user clicks it, the user receive a zip archive (download) that includes the HTML page that the user created and (this is the problem) all other dependencies, like CSS, JS and font files.
How can I do that?
Note:
- I can put all of them inside the HTML page but it will become huge since I have several JS and CSS files.
- I used only JavaScript (and jQuery) to create this page builder and I'm not going to use any server side languages for it (so the download button should use JavaScript and jQuery too).
I have this code to download the current HTML page (but not the dependencies):
window.onload = function() {};
$(document).on('click', 'body', function() {
var txt = $("#test").html();
document.getElementById('link').onclick = function(code) {
this.href = 'data:text/plain;charset=utf-8,' + encodeURIComponent(txt);
};
});
main();