我正在考虑构建一个firefox扩展。 此扩展需要执行屏幕截图的能力。 是否可以仅使用javascript进行此操作?
答案 0 :(得分:6)
更新:除非您正在编写插件,否则此功能已从Firefox中删除。请查看不同的替代方案,请参阅http://badassjs.com/post/12473322192/hack-of-the-day-rendering-html-to-a-canvas和https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow
回到过去,你可以:截取firefox的窗口,是的,这很容易受到伤害。你必须将它渲染到画布中。见https://developer.mozilla.org/en/drawing_graphics_with_canvas#Rendering_Web_Content_Into_A_Canvas
<canvas id='my-canvas'></canvas>
<script>
var canvas = document.getElementById('my-canvas');
var ctx = canvas.getContext("2d");
// Draw the window at the top left of canvas, width=100, height=200, white background
// drawWindow has been removed :(
ctx.drawWindow(window, 0,0, 100, 200, "rgb(255,255,255)");
// Open another window with the thumbnail as an image
open(canvas.toDataURL("image/png"));
</script>
如果你的意思是整个桌面的截图,我不这么认为