JSFiddle - React, Tailwind, and code Playground

by joshuatz

HTML

<button id="printButton" onclick="printDashboard()">Print Dashboard</button>

<div id="dashboardWrapper"></div>

JavaScript

function printDashboard(){
	document.getElementById('iframeWrapper').contentWindow.print();
}
function nestDashboardInSameOrigin(dashboardUrl){
	var iframeWrapper = document.createElement('iframe');
	var dashboardIframe = '<iframe width="1000" height="400" src="' + dashboardUrl + '"></iframe>"';
	document.getElementById('dashboardWrapper').appendChild(iframeWrapper);
/* 	fetch(dashboardUrl).then(function(res){
		res.text().then(function(html){
		
		})
	}) */
	iframeWrapper.contentWindow.document.open();
	iframeWrapper.contentWindow.document.write(dashboardIframe);
	iframeWrapper.contentWindow.document.close();
	iframeWrapper.style.width='100%';
	iframeWrapper.style.height='100%';
	iframeWrapper.id = 'iframeWrapper';
}
nestDashboardInSameOrigin('https://datastudio.google.com/embed/reporting/0B5FF6JBKbNJxQ1hMRzRiVDlobVU/page/jR7H');