<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浏览器中无效应该怎么修改才对啊?
<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区域会显示默认的网页右键菜单,而不是编辑框的右键菜单
按照你这样的试过了,不行.我的Chrome是最新版的V23, 你试下根本不能编辑的
<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>