How to clear the content of an IFRAME?

前端 未结 10 2469
感情败类
感情败类 2020-12-14 05:17

How do I clear the content of my IFRAME element, using javascript, without loading a blank page into it?

I can figure out to do this: iframe_element.src = \"bl

10条回答
  •  难免孤独
    2020-12-14 05:52

    Just get the Iframe and remove the documentElement from it. The Iframe will be blank

     var frame = document.getElementById("YourFrameId"),
     frameDoc = frame.contentDocument || frame.contentWindow.document;
     frameDoc.removeChild(frameDoc.documentElement);
    

提交回复
热议问题