开发者

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.


It's impossible in pure JavaScript, without using ActiveX.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜