I created a new HTML embedded component with the bottom code:
and I’m trying to change the URL dynamically from the page by adding the following code to my on click:
export function button5_click ( event ) {
$w ( “#myHtmlComponent” ). postMessage ( “https://www.thesun.co.uk/” );
}
the URL should fire to the HTML component and load this “https://www.thesun.co.uk/” URL
but for some reason it doesn’t work.
<style>
body { background: #232323; width: 95%; margin: 0 auto; }
/* Responsive Container for iFrame */
.embed-container { position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden; max-width: 100%; }
.embed-container iframe, .embed-container object, .embed-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
</style>
<title>Tech Ops PH | your < IT / design < partner </title>
Well, first of all, you should check if your button is during some action and the triggering function do work like it should.
Did you have double-checked it already? I think you didn’t. How do i know this?
Because i do not see any checking console-logs in your code.
export function button5_click ( event ) {console.log(“Click”);
$w ( “#myHtmlComponent” ). postMessage ( “https://www.thesun.co.uk/” );}
Now, when you click onto your button and you navigate to the CONSOLE, you will be able to see, what your code does exactly.
What do you see i n your console?
Do you see the → CLICK?
If so, then your button works.
Do the next step and log the next code-line.
Continue doing untill you get the line, where your code crashes.
If NOT–> connect first your button with your page-code using the wix-propety-panel.
The button is working, I got 404 error after clicking on the button
The link was not fire to the embeded, when I replace the event.data with the link it works.
I made a progress… now it works (the site is shown on the embedded) but a second after is disappear
Please advice