I am just wondering if I could take screenshot of a remote website by just giving url to javascript code. This is done in many bookmarking sites. I wonder if that is done through some virtual browser which render the html code, executes the onload javascript and once loaded the screenshot is taken.
Asked
Active
Viewed 2,643 times
2 Answers
2
The Same Origin Policy will make any client side approach to this impossible for the vast majority of websites.
Bookmarking sites use JavaScript to pass the URL to their servers (usually with either XMLHttpRequest or via an <img>
element with the target URI in the query string of the src
) and then use a server side solution (e.g. something built with Selenium or PhantomJS) to generate the screenshot.

Quentin
- 914,110
- 126
- 1,211
- 1,335
2
This can be done with the use of a headless browser like PhantomJS.
Take a look at this github project Pageres which uses PantomJS to take screenshots of websites at various different screen resolutions.

Colin Bacon
- 15,436
- 7
- 52
- 72