复制代码代码如下::
<span style = "font-size: 14px;"> <! docType html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w.w3.org/tr/xhtml1/dtd/xhtml1-transsitional.dtd">
<html xmlns = "http://www.w3.org/1999/xhtml">
<kopf>
<meta http-äquiv = "content-type" content = "text/html; charset = utf-8">
<title> 富文本编辑器 </title>
</head>
<body>
<Fieldset>
<Legende> 编辑区 </legend>
<div>
<form>
字体颜色 :
<auswählen onchange = "setfontcolor (this)">
<option value = "schwarz"> schwarz </option>
<option value = "rot"> rot </option>
<Option Value = "Green"> Green </Option>
<Option Value = "Blue"> Blue </Option>
</select>
字体样式 :
<wählen Sie onchange = "setfontStyle (this)">
<option value = "BOLD"> BOLD </option>
<option value = "italic"> italic </option>
<option value = "unterstreichen"> unterstreichen </option>
<Option Value = "StriketThrough"> StriketThrough </Option>
</select>
字体名称 :
<auswählen onchange = "setfontfamily (this)">
<option value = "serif"> serif </option>
<option value = "sans-serif"> sans-serif </option>
<option value = "monospace"> monospace </option>
<Option Value = "Comic sans ms"> Comic sans </option>
</select>
</form>
</div>
<br/>
<div id = "editableText" contenteditable = "true"> </div>
</fieldset>
<script type = "text/javaScript">
Funktion setFontColor (OBJ)
{
document.execcommand ("prognolor", false, obj.value);
}
Funktion setFontStyle (OBJ)
{
document.execcommand (obj.value, false, null);
}
Funktion setfontfamily (OBJ)
{
document.execcommand ("fontName", false, obj.value);
}
</script>
</body>
</html> </span>
在线演示 : http: //jsfiddle.net/web_code/npnv3/embedded/result/ 不足之处还请谅解 , 提出指正方法