问题
I tried to google it, but without much success.
Here is my problem:
I have something like a drag-and-drop game in jQuery, where the user drags some items (div with img) to the droppable drawing area.
I need a screenshot of the users design so I can put all designs into a gallery page.
My problem is how to get the HTML code into a jpeg/png/gif/canvas/whatever.
Btw. I'm on a shared PHP hosting on the server side.
回答1:
You're doing it wrong. Store each piece's location at all times in javascript, and then just submit that data and re-build the images/locations based on the passed javascript data.
回答2:
The functionality you are describing is extremely complex to write with PHP - but there are services such as www.thumbshots.com or www.browsershots.com that do the same thing. This question has been asked similarly many times before here:
https://stackoverflow.com/search?q=screenshots+with+php
回答3:
You want to build your game in canvas, which can then export itself out as a PNG file that you could then have submitted back to the server.
来源:https://stackoverflow.com/questions/6050953/html-div-to-screenshot