I am using dynamic pages & a dynamic database as part of my WIX Editor website for loading wedding pages for clients to view their films and download from. As of my most recent wedding I have decided to use a new platform to host the completed highlight video on which I would like to show on their page on my website using an embedded iframe script from the host platform which will be unique per wedding couple.
Because the weddings prior to this are using a different system, I am trying to make some code that checks the date of the wedding and if it’s after a certain date, it will populate an iframe element with their custom html code to show their films. I already have it working so it can detect which wedding date it is etc, but I do not understand how to use html/iframes and specifically the postMessage/onMessage functions to be able to populate the iframe with the custom code.
I have tried using ChatGPT with limited success so far, it seems to not understand how wix works with the postMessage and onMessage functions.
This is what I have so far which detects the current item and retrieves their custom html code from the database. (checked using console logs and know it’s working correct)
$w.onReady(function () {
$w('#dynamicDataset').onReady(() => {
let currentItem = $w('#dynamicDataset').getCurrentItem();
let weddingDate = currentItem.weddingDate;
const cutoffDate = new Date('04/08/2023');
if (new Date(weddingDate) > cutoffDate) {
let htmlContent = currentItem.vidflowHtml;
}
});
});
So now what I need to do is get the htmlContent into an iframe element on the page… Help?