通过JavaScript(或别的什么)采取浏览器的屏幕截图 [英] Take Screenshot of Browser via JavaScript (or something else)

查看:151
本文介绍了通过JavaScript(或别的什么)采取浏览器的屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关我希望能够为用户采取当前浏览器窗口尽可能轻松的截图并将其发送到服务器支持的原因。

For support reasons I want to be able for a user to take a screenshot of the current browser window as easy as possible and send it over to the server.

任何(疯狂)的想法?

推荐答案

这似乎是一个JavaScript pretty很大的安全漏洞,如果你能做到这一点。想象一下,一个恶意用户安装在您的网站,code与XSS攻击,然后screenshotting你所有的日常工作​​。试想一下,你的网上银行发生的事情...

That would appear to be a pretty big security hole in JavaScript if you could do this. Imagine a malicious user installing that code on your site with a XSS attack and then screenshotting all of your daily work. Imagine that happening with your online banking...

但是,它是可以做到这样的事情的JavaScript之外。我制定了used屏幕捕获code这样这确实每当用户遇到一个RuntimeException带有附加的截图发送电子邮件至服务台的一个伟大的工作。

However, it is possible to do this sort of thing outside of JavaScript. I developed a Swing application that used screen capture code like this which did a great job of sending an email to the helpdesk with an attached screenshot whenever the user encountered a RuntimeException.

我想你可以使用签名的Java小程序的实验(震撼!恐怖!noooooo!),在角落里挂着。如果有安装时给出相应的安全权限执行,可能被强制执行到那种截图code的。

I suppose you could experiment with a signed Java applet (shock! horror! noooooo!) that hung around in the corner. If executed with the appropriate security privileges given at installation it might be coerced into executing that kind of screenshot code.

为了方便起见,这里是我链接到网站上的code:

For convenience, here is the code from the site I linked to:

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.File;

...

public void captureScreen(String fileName) throws Exception {

   Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
   Rectangle screenRectangle = new Rectangle(screenSize);
   Robot robot = new Robot();
   BufferedImage image = robot.createScreenCapture(screenRectangle);
   ImageIO.write(image, "png", new File(fileName));
}
...

这篇关于通过JavaScript(或别的什么)采取浏览器的屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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