Filling an IFRAME with dynamic content from JavaScript

前端 未结 4 650
囚心锁ツ
囚心锁ツ 2020-12-08 23:03

I have an IFRAME that should be filled with content from JavaScript. Had the content be on the server all I had to do is:

    function onIFrameFill() {
              


        
4条回答
  •  借酒劲吻你
    2020-12-08 23:34

    Similar to Jeffry but using contentDocument instead.

    let iframe = document.querySelector('iframe');
    let doc = iframe.contentDocument;
    doc.open();
    doc.write('Hello world!');
    doc.close();
    

提交回复
热议问题