简体   繁体   中英

JavaScript code to take a screenshot of a website without using ActiveX

I have a JavaScript application that an user interacts with. 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.

Clearly any external services would not be able to do this, I need a JavaScript (or Flash ) script that can save the screen appearance. Is this possible?

Also, as the comment below says, I cannot use ActiveX.

Google is doing this in Google+ and a talented developer reverse engineered it and produced http://html2canvas.hertzen.com/ . To work in IE you'll need a canvas support library such as http://excanvas.sourceforge.net/

I think using JavaScript, you won't be able to due to the security restrictions. Flash, possibly.

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

It is impossible using JavaScript (nor 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.
  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.

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. It's far from elegant, but possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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