使用JavaScript截取网页截图? [英] Take a screenshot of a webpage with JavaScript?

查看:161
本文介绍了使用JavaScript截取网页截图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用JavaScript截取网页截图然后将其提交回服务器?

Is it possible to to take a screenshot of a webpage with JavaScript and then submit that back to the server?

我不太关心浏览器安全问题。因为实施将适用于 HTA 。但是有可能吗?

I'm not so concerned with browser security issues. etc. as the implementation would be for HTA. But is it possible?

推荐答案

我已经通过使用ActiveX控件为HTA做了这个。在VB6中构建控件以获取屏幕截图非常容易。我不得不使用keybd_event API调用,因为SendKeys无法执行PrintScreen。以下是代码:

I have done this for an HTA by using an ActiveX control. It was pretty easy to build the control in VB6 to take the screenshot. I had to use the keybd_event API call because SendKeys can't do PrintScreen. Here's the code for that:

Declare Sub keybd_event Lib "user32" _
(ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Public Const CaptWindow = 2

Public Sub ScreenGrab()
   keybd_event &H12, 0, 0, 0
   keybd_event &H2C, CaptWindow, 0, 0
   keybd_event &H2C, CaptWindow, &H2, 0
   keybd_event &H12, 0, &H2, 0
End Sub

这只能让你获得窗口到剪贴板。

That only gets you as far as getting the window to the clipboard.

另一种选择,如果您想要截图的窗口是HTA,只需使用XMLHTTPRequest将DOM节点发送到服务器,然后创建服务器端的屏幕截图。

Another option, if the window you want a screenshot of is an HTA would be to just use an XMLHTTPRequest to send the DOM nodes to the server, then create the screenshots server-side.

这篇关于使用JavaScript截取网页截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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