首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

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

2013-01-02 
怎样让iframe在Chrome浏览器中变成可编辑的状态啊htmlhead scriptdocument.getElementById(SendMs

怎样让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区域会显示默认的网页右键菜单,而不是编辑框的右键菜单

热点排行