Skip to content

Instantly share code, notes, and snippets.

@saurav28
Created January 29, 2021 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saurav28/a18c5b02c3ad8956faa77ab4736198cd to your computer and use it in GitHub Desktop.
Save saurav28/a18c5b02c3ad8956faa77ab4736198cd to your computer and use it in GitHub Desktop.
Load Google Docs in iframe dynamically
<!DOCTYPE html>
<html>
<head>
<title>SDM Google Integration</title>
<style>
body {
background-color: black;
text-align: center;
color: white;
font-family: Arial, Helvetica, sans-serif;
}
</style>
</head>
<body>
<h1>Embedding google doc as an iframe</h1>
<script>
function prepareFrame(docid) {
var ifrm = document.createElement("IFRAME");
var src = "https://docs.google.com/document/d/" + docid + "/edit?embedded=true"
ifrm.setAttribute("src", src);
ifrm.style.width = "100vw";
ifrm.style.height = "100vh";
document.body.appendChild(ifrm);
}
prepareFrame('<pass the google id of a document owned by you');
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment