在firefox扩展中只使用JS的屏幕截图 [英] take screen shot using only js in firefox extension

查看:171
本文介绍了在firefox扩展中只使用JS的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑构建一个Firefox扩展。
此扩展需要执行屏幕截图的功能。
是否有可能只使用javascript?

解决方案

更新:已经从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);
//画出画布左上方的窗口,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 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

这篇关于在firefox扩展中只使用JS的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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