Script not executed

I am using the html-component on a dynamic page to load item-specific html, in this case a code snippet from Tripadvisor.
When I put the following code into the HTML-source, all goes well:

  • TripAdvisor

but, if I read everything after

from the dataset (and is is coming in perfectly), like this:

Espere

then only the Tripadvisor logo part is displayed, the script is not executed. And the console.log shows the snippet coming in beautifully, just before the InnerHtml.

Is there anyone who can tell me what I am doing wrong?

I believe the body onload is not executed. Try put that somewhere else in code.

OK, since Sam published the two new articles on the HTML-component, I made a new page and tried the example code from Velo: Working with the HTML iframe Element | Help Center | Wix.com
Result: same problem as above. What I did was this:

  1. took the example code (played around with changing span to P or div) and threw the Tripadvisor code snippet at it. Result exactly the same as above mentioned: the first part (holding the Tripadvisor logo is executed, the rest not (just a black dot)
  2. took exactly the same code, threw the buttons on the html-form out and hard copied the Tripadvisor code snippet where it should appear. ANd voila, it worked. Below html:

ad 1) html from example code (working fine with messaging, but no scripting)

.button { background-color: #155DE9; color: white; border: none; padding: 10px 20px; text-align: center; font-family: 'Arial'; } .label { font-family: 'Arial'; } .input { font-size: 14px; }
<script type="text/javascript"> 
  // when a message is received from the page code 

console.log(“Before onmessage”);
window.onmessage = (event) => {
console.log(“have event”);
if (event.data) {
console.log(“message received”);
document.getElementById(“theLabel”).innerHTML = event.data;
}
};

  // send message to the page code 
  function button_click() { 
    window.parent.postMessage(document.getElementById("theMessage").value, "*"); 
  } 
</script> 
HTML Label


< Send Message

If I throw the below snippet at it, it displays just the logo and a black dot below, that´s it:

  • TripAdvisor

ad 2) if I take the same html, throw the buttons/etc out and put the same code snippet where it belongs, it DOES work:





I am sweating on this for two weeks now and whatever I do, the result stays the same: hard coded works, posting the snippet in a message doesn´t.
Is there anyone with a suggestion?