<html>
<head>
<title>使iframe处于编辑状态</title>
</head>
<body>
<iframe id="ifr" width="100%" height="500px"></iframe>
</body>
<script type="text/javascript">
function toggle()
{
var doc=document.getElementById('ifr');
var cstatus = doc.contentWindow.document.designMode.toLowerCase(); //当前编辑状态
if (cstatus=='on')
cstatus = 'off';
else
cstatus='on';
doc.contentWindow.document.designMode=cstatus;
}
toggle();
</script>
本文介绍了一个简单的JavaScript函数toggle,该函数能够切换网页中iframe元素的内容文档到编辑或非编辑状态。通过修改iframe内部文档的designMode属性实现这一功能。
2万+

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



