更新:已经从Firefox中删除,除非你正在编写一个插件。请查找不同的替代方法,请参阅 http: //badassjs/post/12473322192/hack-of-the-day-rendering-html-to-a-canvas 和 developer.mozilla/en-US/docs/Web/API/CanvasRenderingContext2D/drawWindow
回到过去,您可以:截取firefox的窗口,是的,它很容易受到伤害。你必须把它渲染成一个画布。请参阅 developer.mozilla/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); //画出画布左上方的窗口,width = 100,height = 200,白色背景 // drawWindow已经被删除:( ctx.drawWindow(window,0, 0,100,200,rgb(255,255,255)); //用缩略图打开另一个窗口作为图像 open(canvas.toDataURL(image / png)); < / script>如果您的意思是整个桌面的屏幕截图,我不认为所以
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?
解决方案UPDATE: This feature has been removed from Firefox, unless you're writing a plugin. Please look for different alternatives, see badassjs/post/12473322192/hack-of-the-day-rendering-html-to-a-canvas and developer.mozilla/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 developer.mozilla/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
更多推荐
在firefox扩展中只使用JS的屏幕截图
发布评论