Created
April 14, 2016 17:16
-
-
Save afzafri/a12231752dadd72e24a0d9f95f8f9112 to your computer and use it in GitHub Desktop.
save image function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- codes --> | |
<div id="target"> | |
<h1>Test print this</h1> | |
<div class='timetable'></div> | |
</div> | |
<button onclick="saveToImage()" class="saveImg">Save as Image</button> | |
<br><br> | |
<!-- codes --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.saveToImage = function() { | |
html2canvas(document.getElementById("target"), { | |
onrendered: function (canvas) { | |
var img = canvas.toDataURL(); | |
window.open(img); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment