I need help, I am trying to do this few days already.
I have also opened post about it here
I'm trying to load an Iframe from dynamic page to HTML component using postMessage.
Maksim gave me these 2 options:
At the first code, there is no error in the console but nothing happens.
$w.onReady(async () => {
// you can use async/await instead of promises
// don't forget to replace with your dataset id
const embedCode = await $w('#dataset1').getCurrentItem().linkurl;
$w('#html1').postMessage(embedCode);
})
The second option gives me a no function error.
$w.onReady(() => {
$w('#dataset1').getCurrentItem().then(currentItem => {
const embedCode = currentItem.linkurl
$w('#html1').postMessage(embedCode)
})
.catch(error => {
console.warn(error)
})
})
I do understand what you're trying to do...
"...it will load the right embed code for the game, from the dynamic database to an empty HTML component..." --- This cannot be done. There is no way to "fill" an empty HtmlComponent. You can set the website that will be displayed in the HtmlComponent by setting the .src property. For example (from the API docs):
$w("#myHtmlComponent").src = "https://en.wikipedia.org/wiki/HTTPS";
If the service provider can provide you with a URL (with no HTML), then you can change which site to display inside in the HtmlComponent by setting the .src property in code.
You can change the .src property, but you cannot fill in an empty HtmlComponent.