Hi! I’m trying to create dynamic pages that each display multiple iframes (so each page would have multiple iframes and different iframe content, all linked to iframe codes in a dataset). I found some code that allowed me to get one iframe component to pull its iframe code from the dataset, but can’t figure out what to add to the page code to get additional iframes to work.
I’m really new at this — any guidance would be appreciated!
What I have so far:
Example of the code inside the iframe components
<!doctype html>
<html>
<head>
<script type="text/javascript">
window.onmessage = (event) => {
if (event.data) {
document.getElementById("chart1").innerHTML = event.data;
}
};
function sendLoadMessage () {
window.parent.postMessage("LoadOk", "*");
}
</script>
</head>
<body onload="sendLoadMessage ();" style="background-color:white;">
<div id="chart1"></div>
</body>
Page code
$w.onReady(function () {
let html = $w('#zipcodeset').getCurrentItem().chart1;
$w("#html1").onMessage( (event) => {
$w("#html1").postMessage(html);
});
});
Some relevant screenshots