title: Taking screenshot of my current webpage and saving it
body: <p>I have created a webpage with a <code>mail button</code> at the top.  </p>
  
  <pre><code>&lt;button class="btn btn-default btn-sm" style="margin:0px 0px -10px 970px;padding:2px 4px 1px 4px" onclick="genScreenshot()"&gt;
     &lt;span class="glyphicon glyphicon-envelope"&gt;&lt;/span&gt;
  &lt;/button&gt;
  </code></pre>
  
  <p>And the next two <code>html</code> lines for my <code>on click</code> function.   </p>
  
  <pre><code>&lt;a id="test"&gt;&lt;/a&gt;
  &lt;div id="box1"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Now when I click this button it should take a <strong>screen shot</strong> the current page and save it as an image.  For taking screenshot I searched through google and obtained this <code>CSS</code> code.  </p>
  
  <pre><code>&lt;script type="text/javascript" src="js/html2canvas.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/html2canvas.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;                                                                                                             
     function genScreenshot() {
        html2canvas(document.body, {
         onrendered: function(canvas) {
           $('#box1').html("");
           $('#box1').append(canvas);
  
           if (navigator.userAgent.indexOf("MSIE ") &gt; 0 || 
           navigator.userAgent.match(/Trident.*rv\:11\./)) 
           {
             var blob = canvas.msToBlob();
             window.navigator.msSaveBlob(blob,'Test file.png');
           }
           else {
             $('#test').attr('href', canvas.toDataURL("image/png"));
             $('#test').attr('download','screenshot.png');
             $('#test')[0].click();
           }
        }
    });
  }          
  &lt;/script&gt;
  </code></pre>
  
  <p>But I'm not getting the <strong>screenshot</strong>, please help me out here.
  I'm new to <em>stack over flow</em> so please  forgive my grammar mistakes and I would really appreciate if someone changes the question format. Thank you all in advance.</p>