<div class="codetitle"> <span><a style="CURSOR: pointer" data="90363" class="copybut" id="copybut90363" onclick="doCopy('code90363')"><u>复制代码</u></a></span>代码如下:</div> <div class="codebody" id="code90363"> <br><span style="font-size:14px;"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <BR><html xmlns="http://www.w3.org/1999/xhtml"> <br> <br><meta http-equiv="content-type" content="text/html;charset=utf-8"> <br><title>富文本编辑器</title> <br></head> <br> <br><フィールドセット> <br>编辑区凡例> <br><div> <br> <br>文字体颜色: <br><select onchange="setFontColor(this)"> <br><option value="black">Black </option> <br><option value="red">Red </option> <br><option value="green">Green </option> <br><option value="blue">青 </option> <br></select> <br>字体样式: <br><select onchange="setFontStyle(this)"> <br><option value="bold">太字 </option> <br><option value="italic">斜体 </option> <br><option value="underline">下線 </option> <br><option value="striketthrough">StriketThrough </option> <br></select> <br>文字名: <br><select onchange="setFontFamily(this)"> <br><option value="serif">セリフ</option> <br><option value="sans-serif">サンセリフ</option> <br><option value="monospace">monospace </option> <br><option value="comic sans ms">comic sans </option> <br></select> <br></form> <br> </div> <br><br> <br><div id="editableText" contenteditable="true" style="width:400px;min-height:100px;border:2px 破線 #ccc"></div> <br></fieldset> <br><script type="text/javascript"> <br>function setFontColor(obj) <br>{ <br>document.execCommand("forecolor",false,obj.value); <br>} <br>function setFontStyle(obj) <br>{ <br>document.execCommand(obj.value,false,null); <br>} <br>function setFontFamily(obj) <br>{ <br>document.execCommand("fontname",false,obj.value); <br>} <br></script> <br></body> <br></html></span> <br> </div> <br>在中演示:http://jsfiddle.net/Web_Code/nPNv3/embedded/result/ 不足之处还请谅解,提出指正法