iframe设置可编辑状态时当用iframe.contentWindow.document.body.contentEditable= "true";设置是必须等浏览器加载完iframe后才能起作用,所欲该语句必须放在加载iframe语句后面,放在前面的话会出错,如下
var iframe=document.createElement("iframe");
iframe.id="te";
iframe.width="98%";
iframe.height="95%";
iframe.color="red";
iframe.background="black";
iframe.contentWindow.document.body.contentEditable= "true";
document.getElementById("myedit").appendChild(iframe);浏览器加载时会报错
正确的如下
var iframe=document.createElement("iframe");
iframe.id="te";
iframe.width="98%";
iframe.height="95%";
iframe.color="red";
iframe.background="black";
document.getElementById("myedit").appendChild(iframe);
iframe.contentWindow.document.body.contentEditable= "true";

本文介绍了如何正确地将一个iframe元素设置为可编辑状态。关键在于确保在浏览器完成iframe加载之后再设置其内容可编辑属性,否则会导致执行错误。
50

被折叠的 条评论
为什么被折叠?



