how to save specific part of page as image using JavaScript

前端 未结 1 1818
北海茫月
北海茫月 2020-12-09 23:03

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

相关标签:
1条回答
  • 2020-12-09 23:39

    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();
    }
    
    0 讨论(0)
提交回复
热议问题