简体   繁体   English

JavaScript代码,无需使用ActiveX即可获取网站的屏幕截图

[英]JavaScript code to take a screenshot of a website without using ActiveX

I have a JavaScript application that an user interacts with. 我有一个用户与之交互的JavaScript应用程序。 I need to save the appearance of the interface at the current time, crop out the part that I need (or only shot the part that I need by specifying the div), and send it back to the server. 我需要在当前时间保存界面的外观,裁掉我需要的部分(或者只通过指定div来拍摄我需要的部分),然后将其发送回服务器。

Clearly any external services would not be able to do this, I need a JavaScript (or Flash ) script that can save the screen appearance. 显然,任何外部服务都无法做到这一点,我需要一个可以保存屏幕外观的JavaScript(或Flash )脚本。 Is this possible? 这可能吗?

Also, as the comment below says, I cannot use ActiveX. 另外,正如下面的评论所说,我不能使用ActiveX。

Google is doing this in Google+ and a talented developer reverse engineered it and produced http://html2canvas.hertzen.com/ . Google正在Google+中这样做,而且一位才华横溢的开发人员对其进行了反向设计,并制作了http://html2canvas.hertzen.com/ To work in IE you'll need a canvas support library such as http://excanvas.sourceforge.net/ 要在IE中工作,您需要一个画布支持库,例如http://excanvas.sourceforge.net/

I think using JavaScript, you won't be able to due to the security restrictions. 我认为使用JavaScript,由于安全限制,您将无法使用。 Flash, possibly. Flash,可能。

在没有使用ActiveX的情况下,在纯JavaScript中是不可能的。

It is impossible using JavaScript (nor Flash). 使用JavaScript(也不是Flash)是不可能的。 It depends on your constraints, and there are some workarounds. 这取决于您的约束,并且有一些解决方法。

  1. You can take advantage of browser extensions (such as a Firefox add-on), but I guess it does not fit your requierments. 您可以利用浏览器扩展(例如Firefox附加组件),但我认为它不适合您的需求。
  2. The best option I can think of is to construct the DOM tree on the client side, and then post it to remote server. 我能想到的最好的选择是在客户端构建DOM树,然后将其发布到远程服务器。

On the server side nothing really holds you from doing generally anything. 在服务器端,没有什么能阻止你做任何事情。 Using WebKit or even launching Internet Explorer or Firefox, you can create the snapshot server-side. 使用WebKit甚至启动Internet Explorer或Firefox,您可以创建快照服务器端。 It's far from elegant, but possible. 它远非优雅,但可能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM