You must Sign In to post a response.
  • Category: JQuery

    Capture div using html2canvas

    hi all

    in my home.aspx, iam displaying a map dinamically in a div

    now i want to capture that div from home.aspx page and display that in child.aspx page div

    iam using the following code in child.aspx, but nothing is displaying

    <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="js/html2canvas.js"></script>
    <script type="text/javascript" src="js/jquery.plugin.html2canvas.js"></script>
    <script type="text/javascript">

    function Capture() {

    //targetdiv is the home.aspx div


    html2canvas($("#targetdiv"), {


    //displaydiv is the div in chid.aspx


    onrendered: function (displaydiv) {
    document.body.appendChild(displaydiv);
    },
    width: 300,
    height: 300
    });
    };
    </script>
  • #762161
    Hello Rishe,

    Try this code :

    <html>
    <head>
    <style type="text/css">
    div {
    height: 100px;
    width: 100px;
    background-color: #9900FF;
    }
    </style>
    <script type="text/javascript" src="html2canvas.js"></script>
    <script type="text/javascript" src="jquery-1.9.1.js"></script>
    <script language="javascript">
    $(document).ready(function() {
    html2canvas($("#mydiv"), {
    onrendered: function(canvas) {
    var myImage = canvas.toDataURL("image/png");
    window.open(myImage);
    }
    });
    });
    </script>
    </head>
    <body>
    <div id="mydiv">
    </div>
    </body>
    </html>


    Go through the below link of Google Developers :

    https://developers.google.com/chart/interactive/docs/gallery/orgchart


    Hope this will help you.

    Regards,
    Nirav Lalan
    DNS Gold Member
    "Failure is the path of least persistence"


Sign In to post your comments