-3

Say for example i have a div with image source

<div>
<p class="row">With custom CSS</p>
<img src="/images/midhun.jpg">
</div>

On button click i need to open this image screen shot in another div

Can you tell the steps to take the screen shot of that image

Midhun K Nair
  • 21
  • 1
  • 1
  • 2

4 Answers4

1

Assuming, you want to show the image in other div.

HTML:

<div id="main">
    <img src="https://lh5.googleusercontent.com/-XOGfvAHr7HQ/UvoUItkZMZI/AAAAAAAAHJk/IJz5JcUB9dw/w520-h274-no/scopes_in_directives.png" />
</div>
<div id="copy">
</div>
<button id="myButton">Click</button>

Javascript:

$('#myButton').on('click', function() {
    $('#copy').html($('#main').html());
});

Demo: https://jsfiddle.net/tusharj/uapf99nt/

Tushar
  • 85,780
  • 21
  • 159
  • 179
0

You don't need to take any screenshot. The image is already loaded, so you can just show the same image again:

HTML

<div id="originalDiv">
   <img src="/images/midhun.jpg">
</div>
<div id="secondDiv">
   <img src="" />
</div>

CSS

#secondDiv { display:none }

jQuery

$(document).on('click', '#button', function() {
    var img = $('#originalDiv > img').attr('src');
    $('#secondDiv > img').attr('src', img).show();
});
kapantzak
  • 11,610
  • 4
  • 39
  • 61
0

look here. it attempts to render a part of the dom, into an image

http://html2canvas.hertzen.com/

Henrik
  • 2,180
  • 16
  • 29
  • After _What i meant is i should get the image copy of

    tag too.Not the image only but all the contents as image .._ comment, your previous answer was actually right ;)

    – Zee May 26 '15 at 06:22
  • true, but a bit provocative.. This is more useful ;) – Henrik May 26 '15 at 06:28
0

Check this link to take a screenshot..

$(function() { 
$("#btnSave").click(function() { 
    html2canvas($("#widget"), {
        onrendered: function(canvas) {
            theCanvas = canvas;
            document.body.appendChild(canvas);

            canvas.toBlob(function(blob) {
                saveAs(blob, "Dashboard.png"); 
            });
        }
    });
});
}); 
ArunValaven
  • 1,753
  • 2
  • 25
  • 44