0
我有这样的代码,我想每一个点击iframe的内容之后将是无效,后来才我怎样才能定义iframe有空内容?
<div id="code" contenteditable></div>
<iframe id="output"></iframe>
<button onclick="update()">run</button>
<script>
function update() {
var frame = document.getElementById("output");
var frameDoc = frame.contentDocument || frame.contentWindow.document;
var w = document.getElementById("code").textContent;
//************************************
//here is what i want to change
frame.contentWindow === null;
frame.contentWindow.document.write(w);
//************************************
}
</script>
<style>
#code{
width:47%;
height:81.8%;
border:1px solid;
}
#output{
width:47%;
height:80%;
border:1px solid;
position:absolute;
right:0px;
top:0px;
}
</style>
非常感谢你的帮助( - ;
PS-我试图让我的编辑
你需要做的'frame.contentWindow.document.close();'后每次写,那么接下来的写操作将清除。另外为什么不使用frameDoc现在你有它?如果不是,那么一些浏览器会提交页面 – mplungjan
什么是frameDoc? –
您自己的var:var frameDoc = frame.contentDocument || frame.contentWindow.document;' – mplungjan