API Documentation > Javascript API

Create Website Screenshot with Javascript API

When we are preparing the screenshot, user will see a loading animation. When the screenshot is ready to been display, it will switch to the screen shot automatically and smoothly. To implement this feature, you only need add several lines of code base on the IMG Tag API.

Please include our javascript file on your page

<script src="http://www.page2images.com/js/p2i.js"> </script>

To Show Screenshot of Google.com on Your Website

<img id='demo' src='http://api.page2images.com/directlink?p2i_url=http://www.google.com&p2i_key=YOUR_API_KEY'>
<script> var p2i=new page2images(); p2i.thumbnail('demo');</script>

To Show Two Screenshots on Same Page

<img id='demo1' src='http://api.page2images.com/directlink?p2i_url=http://www.google.com&p2i_key=YOUR_API_KEY'>
<img id='demo2' src='http://api.page2images.com/directlink?p2i_url=http://www.google.com&p2i_key=YOUR_API_KEY'>
<script> var p2i1=new page2images(); p2i1.thumbnail('demo1');
var p2i2=new page2images();p2i2.thumbnail('demo2'); </script>

To Show a Screenshot with the Device Picture Like This

<img id='demo' src='http://api.page2images.com/directlink?p2i_url=http://www.google.com&p2i_key=YOUR_API_KEY'>
<script> var p2i=new page2images(); p2i.thumbnail('demo', true); </script>

To Set the Timeout Value

The default time out value is 30 seconds. If you want to control it, just need set it in the call.

<img id='demo' src='http://api.page2images.com/directlink?p2i_url=http://www.google.com&p2i_key=YOUR_API_KEY'>
<script> var p2i=new page2images(); p2i.thumbnail('demo', false, 60); </script>
Sample Codes
Download Java sample source code for website screenshot
Download PHP sample source code for website screenshot
Download Python sample source code for website screenshot
Download PHP sample source code for convert HTML to image
Use Code Generator to Build the Code

Using our Code Generator, you can quickly generate the source code for IMG Tags. Use page2images code generator for website screenshot.

Free Engineering Service

Premium and XLarge rate plan users get free help with writing and testing code. Please contact us if you need help.

version:1.7