Alternatives to iframe srcdoc?

后端 未结 3 1493
无人共我
无人共我 2020-12-14 03:29

Generally I am against the use of iframes, but it solved a particular problem of mine.

The thing is that I have a tinyMCE-editor at a webpage. After the user have ma

3条回答
  •  感动是毒
    2020-12-14 03:35

    You can write to the document of an iframe like this:

    const html = 'foo';
    const iframeDocument = document.querySelector('iframe#foo').contentDocument;
    const content = `${html} `;
    iframeDocument.open('text/html', 'replace');
    iframeDocument.write(content);
    iframeDocument.close();
    

提交回复
热议问题