View Full Version : Take Screenshot with JS?

05-19-2006, 02:43 PM
Is it possible to take a screenshot with javascript and save it? Because I use the drag script from dynamicdrive to make images kinda like a puzzle, so how could I use js to take a screenshot of the final image and save it to a folder?

05-19-2006, 02:44 PM
More specifically, im making it offline, so i want a link that will take a screenshot, save it as a .jpg, .png (my choice) and save it to the root folder

05-19-2006, 03:13 PM
No, it isn't possible.
If you know Java, however, you can use the Robot class to take a screenshot (given the user's permission).

05-20-2006, 07:50 AM
You can however capture the location.href of the page and send the query to a perl script to your server using the html2png command. And make a new javascript array to display the images.

05-20-2006, 07:54 AM
By the way u can download html2png from this: http://marginalhacks.com/Hacks/html2jpg/

05-20-2006, 08:50 AM
Clever, but requires X11, which one doesn't usually find running on a server (contrary to what Dan Brown may think...).

05-21-2006, 02:48 PM
Then I think that there is only one way to do it. Add that kind of functionality to JS 1.5 by downloading either spidermonkey or Rhino from mdc.

05-21-2006, 03:13 PM
Heh :)
Unfortunately, I doubt the Mozilla Foundation would approve such a patch... ;)

05-21-2006, 03:23 PM
Who knows if they do?? anyways it is a client side property.

05-21-2006, 03:56 PM
Because it would be against the principles of browser-embedded ECMAScript, besides introducing hundreds of potential new security holes for a feature hardly anyone would use.

It is a client-side task, yes. That doesn't mean it must be done in ECMAScript.

05-21-2006, 08:11 PM
This is too much work for something that doesn't matter.

Everyone will end up with the same resulting puzzle.

In that case, just have a copy of the original image they can save.

That's it.

Or, if the puzzle really is generated dynamically, just save it as a jpg before slicing it up for them.

And, the only other thing you'd need is a script verifying that they have successfully completed the puzzle.

And you're done.

Easy, right?

05-22-2006, 06:54 AM
or you can use alexa's thumbnails.