这里有个简单的
[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
#editwin {
 font-size: 13px;
 line-height: 150%;
}
#editwin p {
 margin: 0px;
 padding: 0px;
}#editmenu button {
 font-size: 13px;
 color: #000000;
 background-color: #FFFFFF;
 margin: 0px 2px;
 padding: 0px;
 border: 1px solid #333333;
}
#color td {
 font-size: 5px;
 line-height: 5px;
 white-space: pre;
 height: 8px;
 width: 8px;
 overflow: hidden;
 cursor: default;
}
#editmenu {
 background-color: #2542A7;
 width: 401px;
 padding-left: 3px;
 border: 1px solid #000066;
}
#color {
 position:absolute;
 z-index:1;
 margin-top: 20px;
 margin-left: 2px;
 border:1px #000000 solid;
 padding:0px 2px 2px;
 background-color:#D4D0C8;
}
-->
</style>
</head>
<script>
var o_select=null;
function seturl(){
 document.execCommand('CreateLink',true);
}
function setcolor(c){
 o_select.execCommand('ForeColor',true,c);
 document.getElementById('color').style.display='none'
}function setsave(c){
 document.execCommand('SaveAs','mycodes.txt');
}
function colortable(){
 var co1="0",co2="0",co3="0",coo1="00",coo2="00",coo3="00";
 document.write('<table border="0" cellpadding="0" cellspacing="1" bgcolor="#000000">\n');
 document.write('<tr>\n<td onclick="setcolor(this.style.backgroundColor)" onmouseover="colorshow(this.style.backgroundColor)" style="background-color:#000000"> </td>');
 var co=0;
 for(var i=0;i<108;i++){
 if(co % 6 ==0 && co>0) co1=eval(co1+3);
 if(co>0) co2=eval(co2+3);
 if(co % 18 ==0 && co>0) co3=eval(co3+3);
 if(co1>6)co1=0;
 if(co2>15)co2=0;
 if(co3>15)co3=0;
 coo1=colorto16(co1);
 coo2=colorto16(co2);
 coo3=colorto16(co3);
 document.write('<td onclick="setcolor(this.style.backgroundColor)" onmouseover="colorshow(this.style.backgroundColor)" style="background-color:#'+coo1+coo2+coo3+'"> </td>\n');
 co++;
 if((i+1)%18==0) document.write('</tr><tr><td onclick="setcolor(this.style.backgroundColor)" onmouseover="colorshow(this.style.backgroundColor)" style="background-color:#'+coo3+coo3+coo3+'"> </td>');
 }
 co=0;
 co1=9;co2=0;co3=0;coo1="99";coo2="00";coo3="00";
 var red=0,red1="";
 for(var i=0;i<108;i++){
 if(co % 6 ==0 && co>0) co1=eval(co1+3);
 if(co>0) co2=eval(co2+3);
 if(co % 18 ==0 && co>0) co3=eval(co3+3);
 if(co1>15)co1=9;
 if(co2>15)co2=0;
 if(co3>15)co3=0;
 coo1=colorto16(co1);
 coo2=colorto16(co2);
 coo3=colorto16(co3);
 document.write('<td onclick="setcolor(this.style.backgroundColor)" onmouseover="colorshow(this.style.backgroundColor)" style="background-color:#'+coo1+coo2+coo3+'"> </td>\n');
 if((i+1)%18==0 &&i<90){
 red++;
 if(red==1) red1="FF0000"
 if(red==2) red1="00FF00"
 if(red==3) red1="0000FF"
 if(red==4) red1="FFFF00"
 if(red==5) red1="00FFFF"
 document.write('</tr><tr><td onclick="setcolor(this.style.backgroundColor)" onmouseover="colorshow(this.style.backgroundColor)" style="background-color:#'+red1+'"> </td>');
 }
 co++;
 }
 document.write('</tr>\n');
 document.write('</table>\n');
}
function colorto16(num){
 if(num==10) return "AA";
 else if(num==11) return "BB";
 else if(num==12) return "CC";
 else if(num==13) return "DD";
 else if(num==14) return "EE";
 else if(num==15) return "FF";
 else return num+""+num;
}
function colorshow(c){
 document.getElementById('colors1').style.backgroundColor=c;
 document.getElementById('nowcolor').value=c;
}
function upcolor1(c){
 if(c.indexOf('#')<0) c+="#";
 for(var i=c.length;i<7;i++){c+='0';}
 document.getElementById('colors1').style.backgroundColor=c;
}
function colorwin(){
 o_select=document.selection.createRange();
 document.getElementById('color').style.display='';
}
function setB(){
 document.selection.createRange().execCommand('Bold');
}
function setI(){
 document.selection.createRange().execCommand('Italic');
}
function setU(){
 document.selection.createRange().execCommand('Underline');
}
function setsize(c){
 if(c!='') document.selection.createRange().execCommand('FontSize',false,c);
}
function setfont(c){
 if(c!='') document.selection.createRange().execCommand('FontName',false,c);
}
function savefile(){
 var str=document.getElementById('editwin').innerHTML;
 var newsave=window.open('','');
 newsave.document.write(str);
 newsave.document.execCommand('SaveAs');
 newsave.window.close();
 newsave=null; 
// newsave.document.close();
}
</script>
<body>
<div id="editmenu">
 <select onchange="setfont(this.value)">
 <option value="">字体</option>
 <option value="宋体">宋体</option>
 <option value="黑体">黑体</option>
 <option value="楷体_GB2312">楷体</option>
 <option value="仿宋_GB2312">仿宋</option>
 <option value="隶书">隶书</option>
 </select>
 <select onchange="setsize(this.value)">
 <option value="">字号</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>
 <button onclick="setB()">B</button>
 <button onclick="setI()"><I>I</I></button>
 <button onclick="setU()"><U>U</U></button>
 <!--button onclick="seturl()">链接</button-->
 <div id="color" style="display:none;"><table width="172" height="20" border="0" cellpadding="0" cellspacing="2" bgcolor="#D4D0C8">
 <tr>
 <td align="center" id="colors1" style="width:60px;border:#000000 solid 1px;"> </td>
 <td align="center" bgcolor="#FFFFFF" style="width:83px;"><input onkeyup="upcolor1(this.value);" style="font-size:12px; border:#000000 solid 1px; width:81px; padding:0px; margin:0px;text-align: center;" name="nowcolor" type="text" id="nowcolor" maxlength="7" /></td>
 <td align="center" style="width:17px; font-size:12px;line-height: 14px; cursor:hand" onclick="setcolor(document.getElementById('nowcolor').value)">OK</td>
 </tr>
</table>
<script language="javascript">
 colortable();
</script>
</div>
 <button onclick="colorwin()">颜色</button>
 <button onclick="document.execCommand('Undo')">后退</button>
 <button onclick="document.execCommand('Redo')">前进</button>
</div>
<div id="editwin" contenteditable="true" style="width:400px; height:200px; padding:2px; border:#000066 solid 1px;">您当前的位置:IT问题精典回答 -> 文章中心 -> web开发 -> javascript -> 文章内容
 JavaScript,createRange 问一个关于createRange的问题。 作者:不详 来源:本站整理 发布时间:2007-3-1 23:36:46
 发布人:Admin 减小字体 增大字体您当前的位置:IT问题精典回答 -> 文章中心 -> web开发 -> javascript
 -> 文章内容 JavaScript,createRange 问一个关于createRange的问题。 作者:不详 来源:本站整理 发布时间:2007-3-1
23:36:46 发布人:Admin 减小字体 增大字体 ...</div>
<div><button onclick="savefile()">保存并下载</button></div>
</body>
</html>[/CODE]										
					
	
	
	
			


 
											





 
	    

 
	
 
											



