Skip to content

Commit

Permalink
Move iframe script to shared script
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmorton committed Jul 13, 2021
1 parent 3b034f0 commit 010cc73
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
19 changes: 19 additions & 0 deletions js/setIframeHeight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// http://dyn-web.com/tutorials/iframes/height/demo.php
function getDocHeight(doc) {
doc = doc || document;
// stackoverflow.com/questions/1145850/
var body = doc.body, html = doc.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
return height;
}
function setIframeHeight(id) {
var ifrm = document.getElementById(id);
var doc = ifrm.contentDocument? ifrm.contentDocument:
ifrm.contentWindow.document;
ifrm.style.visibility = 'hidden';
ifrm.style.height = "10px"; // reset to minimal height ...
// IE opt. for bing/msn needs a bit added or scrollbar appears
ifrm.style.height = getDocHeight( doc ) + 4 + "px";
ifrm.style.visibility = 'visible';
}
22 changes: 1 addition & 21 deletions rsvp.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,25 +70,5 @@ <h4>Please RSVP by Sep 1, 2021.</h4>
</div>
</body>
<footer>
<script>
// http://dyn-web.com/tutorials/iframes/height/demo.php
function getDocHeight(doc) {
doc = doc || document;
// stackoverflow.com/questions/1145850/
var body = doc.body, html = doc.documentElement;
var height = Math.max( body.scrollHeight, body.offsetHeight,
html.clientHeight, html.scrollHeight, html.offsetHeight );
return height;
}
function setIframeHeight(id) {
var ifrm = document.getElementById(id);
var doc = ifrm.contentDocument? ifrm.contentDocument:
ifrm.contentWindow.document;
ifrm.style.visibility = 'hidden';
ifrm.style.height = "10px"; // reset to minimal height ...
// IE opt. for bing/msn needs a bit added or scrollbar appears
ifrm.style.height = getDocHeight( doc ) + 4 + "px";
ifrm.style.visibility = 'visible';
}
</script>
<script src="js/setIframeHeight.js"></script>
</footer>

0 comments on commit 010cc73

Please sign in to comment.