主题:加粗代码的一点小问题请教
大家好,我刚刚开始研究网络编程,现在在做在线编辑器时遇到一点小问题(以加粗为例)代码如下所示:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="JavaScript">
<!--
function dob(){
content.document.execCommand('bold');
}
//-->
</script>
<body>
<table width="523" height="398" border="0">
<tr>
<td height="40" scope="col"><input type="button" value="加粗" onclick="dob()"></td>
</tr>
<tr>
<td height="39">dfsdsdfsdfsdfsdfsfsfbhfgjhhghjhgjh</td> //这边的字段可以加粗的
</tr>
<tr>
<td colspan="21">
<textarea id="content" rows="25" name="content" cols="90" style="font-size: 10pt"> //为什么在这个textarea文本输入框中的文字点加粗按钮后无法加粗啊???
</textarea>
</td>
</tr>
</table>
</body>
</html>
其它地方的字段都能加粗的,惟独textarea文本输入框中的字段不行,怎样改就可以把textarea文本输入框中选中的字段点击加粗按钮后就能加粗啊?大家帮帮忙啊,不胜感激!谢谢...
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>
<script language="JavaScript">
<!--
function dob(){
content.document.execCommand('bold');
}
//-->
</script>
<body>
<table width="523" height="398" border="0">
<tr>
<td height="40" scope="col"><input type="button" value="加粗" onclick="dob()"></td>
</tr>
<tr>
<td height="39">dfsdsdfsdfsdfsdfsfsfbhfgjhhghjhgjh</td> //这边的字段可以加粗的
</tr>
<tr>
<td colspan="21">
<textarea id="content" rows="25" name="content" cols="90" style="font-size: 10pt"> //为什么在这个textarea文本输入框中的文字点加粗按钮后无法加粗啊???
</textarea>
</td>
</tr>
</table>
</body>
</html>
其它地方的字段都能加粗的,惟独textarea文本输入框中的字段不行,怎样改就可以把textarea文本输入框中选中的字段点击加粗按钮后就能加粗啊?大家帮帮忙啊,不胜感激!谢谢...