The other solutions use innerHTML
, which won't always work in XHTML. They also only clear document.body
(anything in the <head>
is still present). Here is a solution that uses the DOM:
var frame = document.getElementById("myFrame"),
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.removeChild(frameDoc.documentElement);
This solution uses innerHTML
:
var frame = document.getElementById("myFrame"),
frameDoc = frame.contentDocument || frame.contentWindow.document;
frameDoc.documentElement.innerHTML = "";
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…