如何使用JavaScript将页面的特定部分保存为图像 [英] how to save specific part of page as image using JavaScript

查看:151
本文介绍了如何使用JavaScript将页面的特定部分保存为图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用JavaScript创建网格,我想将一些丢弃的图像保存为网格作为图像。这是我的链接

I have create grid using JavaScript and I want to save that grid with some dropped image as a image. here is my link

推荐答案

如果你可以使用canvas元素和firefox扩展来限制这种用法 - 所以firefox实际上是你可以加载DOM的任何部分画布的画布和提取图像。基本上:

If you can restrict this usage to browsers using canvas elements, and with firefox extensions -- so firefox in fact, you can load any part of the DOM in a canvas and extract image for the canvas. Basically:

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();
}

这篇关于如何使用JavaScript将页面的特定部分保存为图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆