My questions is almost exactly like the one here: https://www.wix.com/corvid/forum/community-discussion/dynamic-page-with-html-embedded-with-url-from-database?origin=auto_suggest
Currently I’m using the postMessage thing with corvid and code:
import wixData from 'wix-data';
$w.onReady(function () {
wixData.query('Items')
.find()
.then(res => {
let DataRow = res.items;
let strURL = res.items[0].url; // Getting first url for simplicity
$w("#html1").postMessage(strURL);
});
});
HTML Element:
<html>
<head>
<script type="text/javascript">
window.onmessage = (event) => {
if (event.data) {
document.getElementById("jack").src = event.data;
}
};
</script>
</head>
<body>
<script id="jack" type="text/javascript"></script>
</body>
</html>
A quick look at inspect element shows that its properly setting the src of the script, but nothing else is happening. I’ve tried every variant of this and sometimes I get the error X-FRAME option set to sameorigion… and sometimes ‘Failed to execute ‘write’ on ‘Document’: It isn’t possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened.’…
Has anyone successfully loaded an iframe from an external domain dynamically via postMessage?