把代码保存为html 看下效果 把代码的函数看懂就OK了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function bj(x,y) {
zt=ed.document.selection.createRange()
zt.execCommand(x,false,y)
}
function kg(s) {
ed.focus()
ed.document.designMode=s
}
function gb(d) {
ed.document.designMode=d
}
function ys(){
window.open("ys.html","ys","height=100","width=100")
}
</script>
</head>
<body>
<table width="700" border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">
<tr>
<td height="61" colspan="2" align="left" valign="top" bgcolor="#FFFFFF"><label>
<input type="button" name="jc" id="jc" value="加粗"
onclick="bj('Bold')"/>
<input name="xt" type="button" id="xt" value="斜体" onclick="bj('Italic')"/>
</label>
<label>
<select name="select" id="select" onchange="bj('FontName',this.value)">
<option value="宋体">宋体</option>
<option value="华文行楷">华文行楷</option>
</select>
<select name="select2" id="select2" onchange="bj('FontSize',this.value)">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
<input type="button" name="xhx" id="xhx" value="下划线"
onclick="bj('Underline')" />
<input type="button" name="jz" id="jz" value="居中" onclick="bj('JustifyCenter')"/>
<input type="button" name="zm" id="zm" value="字幕" onclick="bj('InsertMarquee')"/>
<input type="button" name="fz" id="fz" value="复制"
onclick="bj('Copy')"/>
<input type="button" name="nt" id="nt" value="粘贴" onclick="bj('Paste')"/>
<a href="yl.html" target="_blank">预览</a>
<br />
<input type="button" name="Submit3" value="超链接" onclick="bj('CreateLink')"/>
<br />
</label></td>
</tr>
<tr>
<td width="132" height="378" align="left" valign="top" bgcolor="#FFFFFF"><label></label>
<label>
<input type="button" name="Submit" value="打开编辑"
onclick="kg('on')"/>
</label>
<p>
<label>
<input type="button" name="Submit2" value="关闭编辑"
onclick="gb('off')"/>
</label>
</p></td>
<td width="565" align="left" valign="top" bgcolor="#FFFFFF"><iframe name="ed" height="400" width="500" frameborder="0"></iframe></td>
</tr>
</table>
</body>
</html>