Take a screenshot of a webpage with JavaScript?

题意:

用 JavaScript 截取网页截图?

问题背景:

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

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

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

由于这个实现是针对 HTA(HTML 应用程序)的,我并不太担心浏览器安全问题等。但这是否可行呢?

问题解决:

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:

我在 HTA(HTML 应用程序)中通过 ActiveX 控件实现了这一功能。用 VB6 构建截取屏幕的控件相当容易。由于 SendKeys 方法无法模拟 PrintScreen 键,我不得不使用 keybd_event API 调用。以下是相关代码:

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.

这只能帮你把窗口内容复制到剪贴板中。

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.

另一种选择是:如果需要截图的窗口是 HTA(HTML 应用程序),可以通过 XMLHTTPRequest 将 DOM 节点发送到服务器,然后在服务器端生成截图。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

营赢盈英

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值