<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;"> <br> <br> <br><meta http-equiv="content-type" content="text/html;charset=utf-8"> <br><title>富文本编辑器</title> <br> <br> <br><fieldset> <br><legend>编辑区</legend> <br><div> <br><form> <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">Blue </option> <br></select> <br>字体样式: <br><select onchange="setFontStyle(this)"> <br><option value="bold">Bold </option> <br><option value="italic">Italic </option> <br><option value="underline">Underline </option> <br><option value="striketthrough">StriketThrough </option> <br></select> <br>字体名称: <br><select onchange="setFontFamily(this)"> <br><option value="serif">Serif </option> <br><option value="sans-serif">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 dashed #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> <br></span> <br> </div> <br>在线演示:http://jsfiddle.net/Web_Code/nPNv3/embedded/result/ 不足之处还请谅解,提出指正方法