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