我使用JavaScript创建了网格,我希望将一些丢弃的图像保存为网格作为图像.这是我的链接
如果您可以将此用法限制为使用 canvas 元素和 firefox 扩展的浏览器 - 事实上,在 firefox 中,您可以在画布中加载 DOM 的任何部分并为画布提取图像。基本上:
canvas = document.getElementById("#acanvas");
if (canvas.getContext) {
var context = canvas.getContext('2d');
context.drawWindow(here_any_part_of_the_DOM_tree_not_only_window);
var mypng = context.toDataURL();
}
Run Code Online (Sandbox Code Playgroud)