Multiple iframes on a dynamic page?

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

If what you have is working OK, then you just need to add an additional iFrame (HtmlComponent) to the page, and add the code for that iFrame using that iFrame’s element ID. I imagine that the code would be something like this:

let item = $w('#zipcodeset').getCurrentItem();
$w("#html1").onMessage((event) => {
    $w("#html1").postMessage(item.chart1);
});
$w("#html2").onMessage((event) => {
    $w("#html2").postMessage(item.chart2);
});

Perfect! Thank you so much for your help!

Hi Yisrael,

I’m doing the same with @C Dov is doing, I copied your code for the page and also his, but i can’t get mine to work yet atm. here is the code I have for the iframe.

<!doctype html>

the dataset field I am trying to source from is under “Tour”
Am I doing something wrong?

I’m doing the same as you are atm, I tried using your code as I am not well versed with coding but I can’t seem to make it work for mine,

Did I input something wrong?

Hello
Is it possible to add an iFrame within a repeater?
Thanks in advance