在firefox扩展中只使用JS的屏幕截图

编程入门 行业动态 更新时间:2024-10-15 04:20:42
本文介绍了在firefox扩展中只使用JS的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在考虑构建一个Firefox扩展。 此扩展需要执行屏幕截图的功能。 是否有可能只使用javascript?

解决方案

更新:已经从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的屏幕截图

本文发布于:2023-11-30 03:37:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1648593.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:截图   屏幕   firefox   JS

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!