日期:2014-05-16  浏览次数:20452 次

文本编辑器怎么实现?
文本编辑器怎么实现?

我想练习下JS

但是不知道如何获得文本编辑框里面的内容

也不知道如何获得鼠标选择中的内容

希望各位指教一下

已经有的代码如下:

edit.htm

<table   width= "500 ">
<tr>
<td> <input   type= "button "   value= "获得信息 "   onclick= "alert(tempframe) "> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td   colspan= "3 ">
<iframe   src= "text.htm "   id= "tempframe "   name= "tempframe "   width= "800 "   scrolling= "yes "> </iframe>
<script   language= "javascript ">
window.frames[ "tempframe "].document.designMode= "On ";
</script>
</td>
</tr>
</table>


<script>
function   addStrong()
{
tempframe.innerHTML= " <strong> "+tempframe.innerHTML+ " </strong> ";
}
</script>

text.htm文件为一个空的文件,无内容

------解决方案--------------------
<input type= "button " value= "获得信息 " onclick= "alert(tempframe.document.getElementsByTagName( 'BODY ')[0].innerHTML) ">