I am thinking of building a firefox extension. This extension requires the ability of performing screen shots. Is it possible doing so only using javascript?
Asked
Active
Viewed 3,740 times
3
-
2If I were a younger man, brash and bold, fearless, I would tempt fate and provide a real answer reading simply, "No." – Pointy Jan 20 '11 at 00:13
1 Answers
6
UPDATE: This feature has been removed from Firefox, unless you're writing a plugin. Please look for different alternatives, see http://badassjs.com/post/12473322192/hack-of-the-day-rendering-html-to-a-canvas and https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow
Back in the days, you could: take a screenshot of firefox's window, yes, and it was so easy it hurt. You had to render it into a canvas. See 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>
If you mean a screenshot of the entire desktop, I don't think so

Ruan Mendes
- 90,375
- 31
- 153
- 217
-
-
2I'm not sure what you mean, this has been around since before HTML5 was called HTML5. This is only supported by firefox's canvas like I mentioned – Ruan Mendes Feb 07 '11 at 16:40
-
1The string "2D" should be small i.e. `var ctx = canvas.getContext("2d");` – Uzair Farooq Sep 08 '13 at 08:47
-
2Hmm... trying this in the Web Console of Firefox 39, and `ctx.drawWindow` seems not to exist, but `ctx.drawImage` does - but it has a different syntax ?! – sdaau Jul 04 '15 at 02:28