Iframe auto fix to content height

by Seth Chouinard

HTML

<iframe src="https://docs.google.com/document/d/e/2PACX-1vRmGYsMitEF8aX-EspaCoJhiITPhxFPDmRl5QKkoCvAWZqEOhvCwORxEMO8lT_NZ279d0NYw87tFCtW/pub?embedded=true" border="0" id="external-frame"></iframe>

CSS

*{margin:0; padding:0;}
iframe{width:100%; border:0;}

JavaScript

/*
		 * When the iframe is on a different subdomain, uncomment the following line
		 * and change "example.com" to your domain.
		 */
	 document.domain = "google.com";
		function setIframeHeight(iframe) {
			if (iframe) {
				var iframeWin = iframe.contentWindow || iframe.contentDocument.parentWindow;
				if (iframeWin.document.body) {
					iframe.height = iframeWin.document.documentElement.scrollHeight || iframeWin.document.body.scrollHeight;
				}
			}
		};

		window.onload = function () {
			setIframeHeight(document.getElementById('external-frame'));
		};