createFile

/*http://stackoverflow.com/questions/24227331/how-to-create-a-base64-file-from-nothing#comment37414517_24227331*/

by guest271314

HTML

<div id="results">Click</div>

JavaScript

$(function () {

    function createFile(_data) {
        var _data = ["<!doctype html>",
            "<img style=width:64px;height:64px;background-color:red;display:block; />"];
        var data = window.btoa(_data.join("").toString());
        var file = "data:text/html;base64," + data;
        alert(file);
        document.location.href = file;
    };
    $("#results").on("click", createFile)
})