No, I don't know of a way to 'screenshot' an element, but what you could do, is draw the quiz results into a canvas element, then use the HTMLCanvasElement
object's toDataURL
function to get a data:
URI with the image's contents.(不,我不知道“截屏”元素的方法,但是您可以做的是将测验结果绘制到canvas元素中,然后使用HTMLCanvasElement
对象的toDataURL
函数获取data:
带有图像内容的URI 。)
When the quiz is finished, do this:(测验完成后,请执行以下操作:)
var c = document.getElementById('the_canvas_element_id');
var t = c.getContext('2d');
/* then use the canvas 2D drawing functions to add text, etc. for the result */
When the user clicks "Capture", do this:(当用户单击“捕获”时,请执行以下操作:)
window.open('', document.getElementById('the_canvas_element_id').toDataURL());
This will open a new tab or window with the 'screenshot', allowing the user to save it.(这将打开带有“屏幕截图”的新标签或窗口,允许用户保存它。)
There is no way to invoke a 'save as' dialog of sorts, so this is the best you can do in my opinion.(无法调用各种“另存为”对话框,因此我认为这是您可以做的最好的事情。) 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…