1

Is it possible to capture the particular div content and div contains images or text or anything?

if any possible ways with script please tell me.

Brian Webster
  • 30,033
  • 48
  • 152
  • 225
Daya
  • 1,170
  • 10
  • 22

1 Answers1

3

I don't know of a way to 'screenshot' an element, but what you could do, is draw the the div into a canvas element, then use the HTMLCanvasElement object's toDataURL function to get a data: URI with the image's contents.

as

var c = document.getElementById('the_canvas_element_id');
var t = c.getContext('2d');
/* then use the canvas 2D drawing functions to add text, etc. for the result */

When the user clicks "Capture", do this:

window.open('', document.getElementById('the_canvas_element_id').toDataURL());

This will open a new tab or window with the 'screenshot', allowing the user to save it.

Raab
  • 34,778
  • 4
  • 50
  • 65
  • http://stackoverflow.com/questions/6887183/how-to-take-screen-shot-of-a-div-with-javascript?rq=1 – GautamD31 Feb 22 '13 at 07:38
  • 1
    @Rab Nawaz... its copy of answer http://stackoverflow.com/questions/6887183/how-to-take-screen-shot-of-a-div-with-javascript?rq=1 instead of this type of answers better to keep link... any way thanks for your response.. – Daya Feb 22 '13 at 09:03