Fix iframes in Safari PWA
parent
17ba536801
commit
dc255c3dda
|
@ -23,8 +23,10 @@ async function init() {
|
|||
try {
|
||||
const result = await syscall("widget.render", lang, body);
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.srcdoc = panelHtml; // set as a global
|
||||
iframe.src = "about:blank";
|
||||
|
||||
iframe.onload = () => {
|
||||
iframe.contentDocument.write(panelHtml);
|
||||
iframe.contentWindow.postMessage({
|
||||
type: "html",
|
||||
theme: document.getElementsByTagName("html")[0].getAttribute(
|
||||
|
|
|
@ -9,7 +9,7 @@ export function createWidgetSandboxIFrame(
|
|||
onMessage?: (message: any) => void,
|
||||
) {
|
||||
const iframe = document.createElement("iframe");
|
||||
iframe.srcdoc = panelHtml;
|
||||
iframe.src = "about:blank";
|
||||
|
||||
const messageListener = (evt: any) => {
|
||||
(async () => {
|
||||
|
@ -67,6 +67,9 @@ export function createWidgetSandboxIFrame(
|
|||
};
|
||||
|
||||
iframe.onload = () => {
|
||||
iframe.contentDocument!.write(panelHtml);
|
||||
// return;
|
||||
|
||||
// Subscribe to message event on global object (to receive messages from iframe)
|
||||
globalThis.addEventListener("message", messageListener);
|
||||
// Only run this code once
|
||||
|
|
Loading…
Reference in New Issue