读书人

怎么让iframe在Chrome浏览器中变成可编

发布时间: 2013-01-02 13:08:45 作者: rapoo

怎样让iframe在Chrome浏览器中变成可编辑的状态啊


<html>
<head>
<script>
document.getElementById(""SendMsg"").contentWindow.document.designMode = "on";
</script>
</head>
<body>
<iframe src=""001.htm"" id=""SendMsg"" width=""100%"" height=""120px"" ></iframe>
</body>
</html>

请教一下,用这个JS脚本让iframe变成编辑状态(可以让用户输入文字),在Chrome浏览器中无效应该怎么修改才对啊?
[解决办法]


<html>
<head>

</head>
<body>
<iframe src=""001.htm"" id=""SendMsg"" width=""100%"" height=""120px"" ></iframe>
<script>
document.getElementById(""SendMsg"").contentWindow.document.body.contentEditable= "true";
</script>
</body>
</html>

这样就可以了,因为运行到JS的时候,这个iframe还没有加载,当然就不能实现效果了。

还有尽量使用contentEditable="true"来设置可编辑,因为designMode的时候右键点击iframe区域会显示默认的网页右键菜单,而不是编辑框的右键菜单

读书人网 >asp.net

热点推荐