JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.0/html2canvas.js"></script>
<div id="content"></div>
JavaScript
function iframeLoad(iframe) {
var body = $(iframe).contents().find('body');
html2canvas(body, {
onrendered: function( canvas ) {
$("#content").empty().append(canvas);
},
allowTaint: true,
taintTest: false,
logging: true
});
}
$(document).ready(function() {
var url = "http://www.cnn.com";
var urlParts = document.createElement('a');
urlParts.href = url;
$.getJSON("http://html2canvas.appspot.com/query?callback=?", { xhr2:false, url:urlParts.href }, function(html) {
iframe = document.createElement('iframe');
$(iframe).css({ 'visibility':'hidden'}).width($(window).width()).height($(window).height());
$('#content').append(iframe);
d = iframe.contentWindow.document;
d.open();
$(iframe.contentWindow).load(iframeLoad.bind(null, iframe));
$('base').attr('href',urlParts.protocol+"//"+urlParts.hostname+"/" + urlParts.pathname);
html = html.replace("<head>","<head><base href='"+urlParts.protocol+"//"+urlParts.hostname+"/" + urlParts.pathname + "' />");
if($("#disablejs").prop('checked')){
html = html.replace(/\<script/gi,"<!--<script");
html = html.replace(/\<\/script\>/gi,"<\/script>-->");
}
d.write(html);
d.close();
});
});