Skip to content

Instantly share code, notes, and snippets.

@ndesmic
Created November 22, 2016 21:27
Show Gist options
  • Save ndesmic/965e4bd6c39fc20b9fbc8879a591b454 to your computer and use it in GitHub Desktop.
Save ndesmic/965e4bd6c39fc20b9fbc8879a591b454 to your computer and use it in GitHub Desktop.
(function() {
var scripts = document.getElementsByTagName( 'script' );
var thisScriptTag = scripts[ scripts.length - 1 ];
for (var index = scripts.length - 1; index >= 0; index--) {
if (scripts[index].src.indexOf("iframe.js") > -1) {
thisScriptTag = scripts[index];
break;
}
}
console.log(thisScriptTag);
var iframe = document.createElement('iframe');
iframe.src = thisScriptTag.src.replace(/\.js/,'.html');
iframe.src += '&docUrl='+encodeURIComponent(window.location.href);
iframe.frameBorder = 0;
iframe.setAttribute('webkitallowfullscreen', 'true');
iframe.setAttribute('height', thisScriptTag.getAttribute('height') || "100%");
iframe.setAttribute('width', thisScriptTag.getAttribute('width') || "100%");
thisScriptTag.parentNode.insertBefore(iframe, thisScriptTag.nextSibling);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment