6

我有一个 ASP.Net 应用程序,作为所需的功能,用户希望能够截屏。虽然我知道这可以模拟,但如果有一种方法可以获取 URL(或当前呈现的页面)并将其转换为可以存储在服务器上的图像,那就太好了。

这是疯了吗?有没有办法做到这一点?如果有,有参考吗?

4

6 回答 6

6

我现在可以告诉你,在浏览器内部没有办法做到这一点,也不应该有. 想象一下,您的页面在 iframe 中嵌入了 GMail。然后,您可以窃取此人的 GMail 收件箱的屏幕截图!

这可以通过让浏览器“屏蔽”所有违反跨域限制的 iframe 和嵌入来确保安全。

您当然可以编写一个扩展来执行此操作,但请注意上述安全注意事项。

更新:您可以使用画布实用程序函数来获取与您的代码同源的页面的屏幕截图。甚至还有一个库可以让你这样做:http ://experiments.hertzen.com/jsfeedback/

你可以在这里找到其他可能的答案:Using HTML5/Canvas/JavaScript to take screenshots

于 2008-10-21T01:14:15.443 回答
3

Browsershots有一个 XML-RPC 接口和可用的源代码(在 Python 中)。

于 2008-10-21T01:08:55.030 回答
3

我使用了免费的程序集 UrlScreenshot.dll,您可以在此处下载。

效果很好!

还有WebSiteScreenShot但它不是免费的。

于 2008-10-21T02:00:16.597 回答
1

您可以尝试一个浏览器插件,例如IE7 Pro for Internet Explorer,它允许您将当前站点的屏幕截图保存到磁盘上的文件中。我敢肯定那里也有类似的 FireFox 插件。

于 2008-10-21T01:30:57.000 回答
1

如果你想做你描述的事情。您需要调用一个打印 IE 输出的外部进程,如此处所述

于 2008-10-21T02:00:52.773 回答
1

你为什么不采取另一种方法?

If you have the need that users can view the same content over again, then it sounds like that is a business requirement for your application, and so you should be building it into your application.

Structure the URL so that when the same user (assuming you have sessions and the application shows different things to different users) visits the same URL, they always see same thing. They can then bookmark the URL locally, or you can even have an application feature that saves it in a user profile.

Part of this would mean making "clean urls", eg, site.com/view/whatever-information-needed-here.

If you are doing time-based data, where it changes as it gets older, there are probably a couple possible approaches.

  • If your data is not changing on a regular basis, then you could make the "current" page always, eg, site.com/view/2008-10-20 (add hour/minute/second as appropriate).
  • If it is refreshing, and/or updating more regularly, have the "current" page as site.com/view .. but allow specifying the exact time afterwards. In this case, you'd have to have a "link to this page" type function, which would link to the permanent URL with the full date/time. Look to google maps for inspiration here-- if you scroll across a map, you can always click "link to here" and it will provide a link that includes the GPS coordinates, objects on the map, etc. In that case it's not a very friendly url but it does work quite well. :)
于 2008-10-21T03:03:21.697 回答