复制代码代码如下:
<span style = "font-size: 14px;"> <! doctype html public "-// w3c // dtd xhtml 1.0 transitional // en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.transitional.org/tr/xhtml1/dtd/xhtml1-trans
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<title> 富文本编辑器 </title>
</head>
<body>
<fieldset>
<gregend> 编辑区 </gendend>
<div>
<form>
字体颜色:
<เลือก onChange = "setFontColor (นี่)">
<ตัวเลือกค่า = "ดำ"> ดำ </potion>
<ตัวเลือกค่า = "สีแดง"> สีแดง </potion>
<ตัวเลือกค่า = "สีเขียว"> สีเขียว </potion>
<ตัวเลือกค่า = "สีน้ำเงิน"> สีน้ำเงิน </potion>
</เลือก>
字体样式:
<เลือก onChange = "setFontStyle (นี่)">
<ตัวเลือกค่า = "ตัวหนา"> ตัวหนา </potion>
<ตัวเลือกค่า = "italic"> italic </opovie>
<ตัวเลือกค่า = "ขีดเส้นใต้"> ขีดเส้นใต้ </potion>
<ตัวเลือกค่า = "striketthrough"> striketthrough </potion>
</เลือก>
字体名称:
<เลือก onChange = "setFontFamily (นี้)">
<ตัวเลือกค่า = "serif"> serif </potion>
<ตัวเลือกค่า = "sans-serif"> sans-serif </portion>
<ตัวเลือกค่า = "monospace"> monospace </pontion>
<ตัวเลือกค่า = "Comic Sans MS"> Comic Sans </potion>
</เลือก>
</form>
</div>
<br/>
<div id = "editableText" contenteditable = "true"> </div>
</fieldset>
<script type = "text/javascript">
ฟังก์ชั่น setFontColor (obj)
-
document.execcommand ("porteolor", false, obj.value);
-
ฟังก์ชั่น setFontStyle (OBJ)
-
document.execcommand (obj.value, false, null);
-
ฟังก์ชั่น setFontFamily (obj)
-
document.execcommand ("fontname", false, obj.value);
-
</script>
</body>
</html> </span>
在线演示: http: //jsfiddle.net/web_code/npnv3/embedded/result/ 不足之处还请谅解, 提出指正方法提出指正方法