实现iframe可编辑用到 document.designMode='on'(允许编辑)
1.
Code
<body onload="f.document.designMode='on'">
<iframe id="f"></iframe>
<button onclick="f.document.body.innerHTML=''">清空</button>
<button onclick="alert(f.document.documentElement.outerHTML)">代码</button>
</body>
2. frames :获取给定文档定义或与给定窗口关联的文档定义的所有 window 对象的集合(取得window对象集合)
Code
<iframe id="if"></iframe>
<button onclick="window.frames.f.document.body.innerHTML=''">清空</button>
<button onclick="alert(window.frames.f.document.documentElement.outHTML)">输出 代码</button>
<script>
window.frames.f.document.designMode='on';
</script>