以JavaScript產生可下載檔案-Object URL

by on # javascript

Code

<script>
$(":button").click(function () {
    html2canvas($("#wrap")[0], {
        onrendered: function (canvas) {
            var $div = $("#output");
            $div.empty();
            $("<img />", { src: canvas.toDataURL("image/png") }).appendTo($div);
            //$("<img />", { src: img }).appendTo($div);
        }
    });
});
</script>

下面我在CodePen有做一個範例,可參考。

javascript, Object URL
comments powered by Disqus