Single and Multiple iframe Examples
Use the following Dynamic iframe height code examples to help avoid scroll traps:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
<html>
<head>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
//if we get some data back
if (event.data && event.data.params && event.data.params.height) document.getElementById("iframe1").style.height = event.data.params.height;
}
</script>
</head>
<body>
<iframe
id="iframe1"
src="https://public.domo.com/embed/pages/abcde"
width="100%"
height="1620"
marginheight="0"
marginwidth="0"
frameborder="0"
></iframe>
</body>
</html>
<html>
<head>
<script>
window.addEventListener("message", receiveMessage, false);
function receiveMessage(event) {
var frames = document.getElementsByTagName('iframe');
for (var i =0; i <frames.length; i++) {
//loop through the responses and determine which came from which source
if (frames[i].contentWindow === event.source) {
if (event.data && event.data.params && event.data.params.height) frames[i].style.height = event.data.params.height + 15;
}
}
}
</script>
</head>
<body>
<iframe
id="iframe1"
src="https://public.domo.com/embed/pages/abcde"
width="100%"
height="1620"
marginheight="0"
marginwidth="0"
frameborder="0"
></iframe>
<iframe
id="iframe2"
src="https://public.domo.com/embed/pages/fghij"
width="100%"
height="1620"
marginheight="0"
marginwidth="0"
frameborder="0"
></iframe>
</body>
</html>