diff --git a/src/pages/LiveEditor/BasicEditor.tsx b/src/pages/LiveEditor/BasicEditor.tsx index 119e87c3d..2ca0adba4 100644 --- a/src/pages/LiveEditor/BasicEditor.tsx +++ b/src/pages/LiveEditor/BasicEditor.tsx @@ -26,12 +26,6 @@ const BasicEditor = () => { } const iframe = iframeRef.current; - const document = iframe.contentDocument; - - if (!document) { - alert("iframe contentDocument is not available"); - return; - } const documentContents = ` @@ -46,9 +40,7 @@ const BasicEditor = () => { `; - document.open(); - document.write(documentContents); - document.close(); + iframe.srcdoc = documentContents; }, [html, css, js]); return ( @@ -210,7 +202,12 @@ const BasicEditor = () => { -