1

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();
Anders
  • 7,431
  • 6
  • 42
  • 76
Amir Khademi
  • 233
  • 1
  • 4
  • 13
  • if it's not possible, it would be good that by clicking on that button, an HTML page create beside the current page builder HTML file (so other dependecies are there and there's no problem) – Amir Khademi Nov 04 '15 at 09:18
  • Maybe this will help you http://stackoverflow.com/questions/27177661/save-html-locally-with-javascript – muuvmuuv Nov 04 '15 at 09:44

0 Answers0