way you can receive results from the embed player. For security reasons, you can only listen to the demo and can't send to it. If you want to run glifs, register a key and run glifs via API. Additionally, check out Val.town + Web Fetcher Block for writing more advanced examples.
Here is the core iframe communication part. Your page recieves events from the glif iframe using postMessage API
<!doctype html>
<script>
window.addEventListener("message", handleMessage, false);
function handleMessage(event) {
const allowedDomains = ["https://glif.app"];
if (!allowedDomains.includes(event.origin)) {
console.warn("ignoring message from untrusted origin");
return;
}
const message = event.data;
if (message.type === "glifRunStarted") {
// handle a glif run starting (e.g. show a loading indicator)
} else if (message.type === "glifRunCompleted") {
// handle a glif run completing (e.g. show the final image)
} else {
// currently only sends those 2 messages so nothing else here yet!
}
}
</script>