<form name="myform"><select name="selsize" onchange="cfont()">
<option selected>字号</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select>
<img src="bold.gif" onclick="cbolt()" alt="粗体">
<img src="italicize.gif" onclick="citalic()" alt="斜体">
<img src="underline.gif" onclick="cunderline()" alt="下划线">
<img src="aleft.gif" onclick="cJustifyLeft()" alt="偏左">
<img src="center.gif" onclick="cJustifyCenter()" alt="居中">
<img src="aright.gif" onclick="cJustifyRight()" alt="偏右">
<img src="fgcolor.gif" onclick="cfontcolor()" alt="字体颜色">
<img src="url.gif" onclick="urllink()" alt="超级链接">
<img src="img.gif" onclick="getimg()" alt="插入图象">
<img src="5.gif" onclick="getemot()" alt="发贴心情">
<img src="quote1.gif" onclick="quete()" alt="引用">
</form>
<iframe id="editor" style="border: black thin; width:100%; height:200px"></iframe>
<SCRIPT LANGUAGE="JavaScript">
<!--
var aa = frames["editor"];
aa.document.designMode = "on";
function cfont(){
var op;
var sel = aa.document.selection.createRange(); //在aa里,也就是浮动框架里选中的,文本内容付给sel
if(sel.text == ""){
alert("请选取内容!");
}
switch(document.myform.selsize.value)
{
case "1":
op=1;
break;
case "2":
op=2;
break;
case "3":
op=3;
break;
case "4":
op=4;
break;
case "5":
op=5;
break;
case "6":
op=6;
break;
case "7":
op=7;
break;
}
sel.execCommand('FontSize',false,op);
}
function cbolt(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}
sel.execCommand('bold');
}
function citalic(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}
sel.execCommand('italic');
}
function cunderline(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}
sel.execCommand('underline');
}
function cJustifyLeft(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
sel.execCommand('justifyLeft');
}
}
function cJustifyCenter(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
sel.execCommand('justifyCenter');
}
}
function cJustifyRight(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
sel.execCommand('justifyRight');
}
}
function cfontcolor(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
var selcolor = showModalDialog("selcolor.html", "", "dialogWidth:18.5em; dialogHeight:18.5em; status:0; help:0");
sel.execCommand('ForeColor',false,selcolor);
}
}
function urllink(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
sel.execCommand('createlink');
}
}
function InsertSymbol(str1)
{
aa.focus();
var edit = aa.document.selection.createRange();
edit.pasteHTML(str1);
}
function getimg(){
var imgdlg = showModalDialog("img.html", "", "dialogWidth:18.5em; dialogHeight:18.5em; status:0; help:0");
var imgstr = "<img src='"+imgdlg[0]+"' border='"+imgdlg[1]+"' style='float:"+imgdlg[2]+"'>" ;
InsertSymbol(imgstr);
aa.focus();
}
function getemot(){
var imgdlg = showModalDialog("emot.html", "", "dialogWidth:28.5em; dialogHeight:18.5em; status:0; help:0");
InsertSymbol(imgdlg);
aa.focus();
}
function quete(){
var sel = aa.document.selection.createRange();
if(sel.text == ""){
alert("请选取内容!");
}else{
var selstr = "<div style='background-color:#F7F709;border:1px;'>"+sel.text+"</div>";
InsertSymbol(selstr);
aa.focus();
}
}
//-->
</SCRIPT>
改变字体大小为什么会 sel.execCommand('FontSize',false,op);写