How to take screenshot of a div with JavaScript?

I am building something called the “HTML Quiz”. It’s completely ran on JavaScript and it’s pretty cool.

At the end, a results box pops up that says “Your Results:” and it shows how much time they took, what percentage they got, and how many questions they got right out of 10. I would like to have a button that says “Capture results” and have it somehow take a screenshot or something of the div, and then just show the image captured on the page where they can right click and “Save image as.”

I really would love to do this so they can share their results with others. I don’t want them to “copy” the results because they can easily change that. If they change what it says in the image, oh well.

Does anyone know a way to do this or something similar?

11 Answers
11

Leave a Comment