Hello communitiy!
I am trying to create a website that contains drag & drop functionality. I try to do this by sending a string that contains HTML code to a HTML iFrame. I have sent HTML code successfully with other different (long and dynamically prepared) HTML strings many times before, and it worked.
At a later stage I will have to update the code using my database, corvid code, etc. to make it dynamic.
But first I am trying to get the drag&drop functionality to work.
The HTML code works fine in following cases:
1: As a standalone HTML file,
2: When copying the code fully into the HTML iFrame.
But I can not achieve the drag & drop functionality to work when the code is sent as a string to the iFrame via .postMessage
Here is the code from the corvid editor:
import wixData from ‘wix-data’ ;
import wixUsers from ‘wix-users’ ;
//\
$w.onReady( function () {
let myStyle = ’ \
let myBody = ’ \
\let myScript = ’ \
' ;let myHtml = myStyle+myBody+myScript;
console.log(myHtml);
$w( “#htmlStPln” ).postMessage(myHtml);
} );
});
The HTML iframe contains the following code:
window.onmessage = (event) => { if (event.data) { document.getElementById("myTab").innerHTML = event.data; } }; *********************** Why is the HTML code working when run completely within the HTML iframe - and not when sent as a string? Any help is appreciated! Thanks Stefan