admin管理员组

文章数量:1415139

I want my users to be able to take a screenshot of the webpage (or me defining the size of the screenshot) and then allowing them to save it to their puter.

Does anyone know of a good JS lib that allows you to do this?

I know there are addons for the browser, but i wanted something pure JS so that the user can just click in a button and a "save as" link apears with a screenshot of what they are looking at.

Thanks for the help.

/fmsf

I want my users to be able to take a screenshot of the webpage (or me defining the size of the screenshot) and then allowing them to save it to their puter.

Does anyone know of a good JS lib that allows you to do this?

I know there are addons for the browser, but i wanted something pure JS so that the user can just click in a button and a "save as" link apears with a screenshot of what they are looking at.

Thanks for the help.

/fmsf

Share Improve this question edited May 14, 2010 at 13:05 fmsf asked May 14, 2010 at 11:53 fmsffmsf 37.2k49 gold badges153 silver badges196 bronze badges 2
  • 2 Not possible, there is no cross-browser solution to create screenshots with pure javascript (assuming there's a pure javascript solution for any browser). – Wolph Commented May 14, 2010 at 11:56
  • Does this answer your question? Using HTML5/Canvas/JavaScript to take in-browser screenshots – Anderson Green Commented Jan 8, 2022 at 12:03
Add a ment  | 

3 Answers 3

Reset to default 4

Browsers don't expose APIs that allow this to web pages, so there is no way to achieve this using plain JavaScript running in a page.

The only way to achieve this would be to have screen grabs prepared on the server, and a normal download link pointing to the appropriate one.

This can't be done in JavaScript. Taking screen shots outside the current document/domain is a potential security problem and is not possible. See my question about getting the pixel colour from the current mouse position for more background.

If you need to transmit the screen shots onto your server, look into external applications that interact with your web site. Open-source bug tracker Mantis for example has a screenshot application for Windows.

If the screenshot and the saving of the file are both to take place on the client puter, check out Fireshot for Firefox. It doesn't seem to offer any interaction capabilities with a pre-defined web site but may be the right tool for your users.

HTML2Canvas (http://html2canvas.hertzen./) recreates the rendered HTML into a canvas. And you can save the canvas as an image. That could do the trick, although it's not 100% accurate (and for good reasons - that would open security holes in browsers if that was possible, see https://stackoverflow./a/1936084/1333479).

本文标签: javascriptGood JS lib to take screenshot of the screenStack Overflow