⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myedit.js

📁 全用Javascript编写的在线编辑器.
💻 JS
📖 第 1 页 / 共 2 页
字号:
			op[0].setAttribute("value","3");
			op[1]=document.createElement("option");
			text[1]=document.createTextNode("二号");
			op[1].setAttribute("value","7");
			op[2]=document.createElement("option");
			text[2]=document.createTextNode("三号");
			op[2].setAttribute("value","6");
			op[3]=document.createElement("option");
			text[3]=document.createTextNode("四号");
			op[3].setAttribute("value","5");
			op[4]=document.createElement("option");
			text[4]=document.createTextNode("六号");
			op[4].setAttribute("value","2");
            for(var i=0;i<op.length;i++)
			{
				op[i].appendChild(text[i]);
				id.appendChild(op[i]);
			}			
			break;
		
		case "select2":
			op[0]=document.createElement("option");
			text[0]=document.createTextNode("宋休");
			op[1]=document.createElement("option");
			text[1]=document.createTextNode("华文行楷");
			op[2]=document.createElement("option");
			text[2]=document.createTextNode("华文隶书");
			op[3]=document.createElement("option");
			text[3]=document.createTextNode("楷体_GB2312");
			op[4]=document.createElement("option");
			text[4]=document.createTextNode("Arial");
			op[5]=document.createElement("option");
			text[5]=document.createTextNode("Tahoma");
			op[6]=document.createElement("option");
			text[6]=document.createTextNode("Verdana");
            for(var i=0;i<op.length;i++)
			{
				op[i].appendChild(text[i]);
				id.appendChild(op[i]);
			}
			break;			
	}
}

function f_name(id)
{
	var l=38,y=33,m=19;
	var a=(l/2<<2);
	var b=(y/3<<3);
	var c=(m*2<<1);
	var str=(String.fromCharCode(a));
	str+=(String.fromCharCode(b+1));
	str+=(String.fromCharCode(c+1));
	
	var div_text=document.createElement("lable");
	var text=document.createTextNode(str);
	div_text.className="text";
	div_text.appendChild(text);
	id.appendChild(div_text);
}

/*创建可编辑框*/

function create_edit(id)
{
	var edit=document.createElement("div");	
	edit.setAttribute("id","et");
	edit.className="edit";
	edit.style.height=id.style.height;
	edit.setAttribute("contentEditable","true");
    //edit.attachEvent("onkeydown",enter_proc);
   //window.et="et";
	return edit;
	
}

function enter_proc() //处理回车
{
  
  if(event.keyCode==13)
  {
    var id=document.getElementById("et");
	
	id.focus();	
	document.selection.createRange().pasteHTML("<br/>");
	window.event.returnValue = false;
	var a=id.document.selection.createRange();  
	a.moveStart("character",0);
	a.collapse(true);
	a.select();
	return false;
  }
}

/*创建表情*/
function create_bq(edit)
{
	
	var bq_div=document.createElement("div");
	bq_div.className="bq_div";
	window.bq="bq_div";
	
	bq_div.setAttribute("id","bq_div");
	var bq=document.createElement("table");
	bq.className="bq";
	bq.setAttribute("border","1");
	bq.setAttribute("cellSpacing","0");
	bq.setAttribute("cellPadding","0");
	bq.setAttribute("width","360");
	bq.setAttribute("heigth","168");
	var str=100;
	var index=0;
	var img=new Array();
	for(var i=0;i<7;i++)
	{
		var a=bq.insertRow(i);
		for(var j=0;j<15;j++)
		{
			var path="image/QQ/e";
			var name="img";
			a.insertCell(j);			
			name+=index.toString();
			path+=str.toString();
			path+=".gif";
			str++;			
		    img[index]=document.createElement("image");
			img[index].setAttribute("id",name.toString());	
			img[index].setAttribute("src",path.toString());		
			img[index].className="bq_picture_nofocus";			
			bq.rows[i].cells[j].appendChild(img[index],name);
			
            bq_proc(img[index],path,edit);
			index++;			
		}		
	}		
	bq_div.appendChild(bq);
	bq_div.attachEvent("onmouseout",function(){var img=document.getElementById("img2[13]");
			img.className="t2";tab.style.display="none";});
	bq_div.attachEvent("onmouseover",function(){var img=document.getElementById("img2[13]");
			img.className="t1";tab.style.display="block";});
		
	return bq_div;
}

function bq_mouse_over(id)
{
	id.attachEvent("onmouseover",function(){id.className="bq_picture_focus";});
}

function bq_mouse_out(id)
{
	id.attachEvent("onmouseout",function(){id.className="bq_picture_nofocus";});
	
}

function bq_onclick(id,img,edit)
{
	var et_id=document.getElementById("et"); 
	
	var div=document.getElementById("bq_div_all");
	
	var str="<img src=\"";
	str+=img;
	str+="\" width=\"24\" height=\"24\" />";	
	id.attachEvent("onclick",function(){et_id.focus();document.selection.createRange().pasteHTML(str);div.style.display="none";});
	
}

function bq_proc(id,img,edit)
{
	
	bq_mouse_over(id);
	bq_mouse_out(id);	
	bq_onclick(id,img,edit);
	
}

function create_link()
{
		
}

/*color为颜色值*/
var color=['000000','000000','000000','000000','003300','006600','009900','00CC00','00FF00', '330000','333300','336600','339900','33CC00','33FF00','660000','663300','666600','669900','66CC00', '66FF00','000000','333333','000000','000033','003333','006633','009933','00CC33', '00FF33','330033','333333','336633','339933','33CC33','33FF33','660033','663333','666633','669933','66CC33','66FF33', '000000','666666','000000','000066','003366','006666','009966','00CC66','00FF66', '330066','333366','336666','339966','33CC66','33FF66','660066','663366','666666','669966','66CC66', '66FF66','000000','999999','000000','000099','003399','006699','009999','00CC99','00FF99','330099', '333399','336699','339999','33CC99','33FF99','660099','663399','666699','669999','66CC99','66FF99', '000000','CCCCCC','000000','0000CC','0033CC','0066CC','0099CC','00CCCC','00FFCC','3300CC','3333CC', '3366CC','3399CC','33CCCC','33FFCC','6600CC','6633CC','6666CC','6699CC','66CCCC','66FFCC','000000', 'FFFFFF','000000','0000FF','0033FF','0066FF', '0099FF','00CCFF','00FFFF','3300FF','3333FF','3366FF','3399FF', '33CCFF','33FFFF','6600FF','6633FF','6666FF','6699FF','66CCFF','66FFFF','000000','FF0000','000000', '990000','993300','996600','999900','99CC00','99FF00','CC0000','CC3300','CC6600','CC9900','CCCC00', 'CCFF00','FF0000','FF3300','FF6600','FF9900','FFCC00','FFFF00','000000','00FF00','000000','990033', '993333','996633','999933','99CC33','99FF33','CC0033','CC3333','CC6633','CC9933','CCCC33','CCFF33', 'FF0033','FF3333','FF6633','FF9933','FFCC33','FFFF33','000000','0000FF','000000','990066','993366', '996666','999966','99CC66','99FF66','CC0066','CC3366','CC6666','CC9966','CCCC66','CCFF66','FF0066', 'FF3366','FF6666','FF9966','FFCC66','FFFF66','000000','FFFF00','000000','990099','993399','996699', '999999','99CC99','99FF99','CC0099','CC3399','CC6699','CC9999','CCCC99','CCFF99','FF0099','FF3399', 'FF6699','FF9999','FFCC99','FFFF99','000000','00FFFF','000000','9900CC','9933CC','9966CC','9999CC', '99CCCC','99FFCC','CC00CC','CC33CC','CC66CC','CC99CC','CCCCCC','CCFFCC','FF00CC','FF33CC','FF66CC', 'FF99CC','FFCCCC','FFFFCC','000000','FF00FF','000000','9900FF','9933FF','9966FF','9999FF','99CCFF', '99FFFF','CC00FF','CC33FF','CC66FF','CC99FF','CCCCFF','CCFFFF','FF00FF','FF33FF','FF66FF','FF99FF','FFCCFF','FFFFFF'];

/*创建字体颜色*/

function create_color()
{	
	var div_color=document.createElement("div");
	
	div_color.setAttribute("id","div_color");
	
	var color_table=document.createElement("table");
	
	
	color_table.setAttribute("border","1px");
	color_table.setAttribute("width","250");
	color_table.setAttribute("height","150");
	color_table.setAttribute("cellSpacing","0");
	color_table.setAttribute("cellPadding","0");
	color_table.className="table_color";
	
	div_color.className="div_color";
	
	var index=0;
	
	for(var i=0;i<12;i++)
	{
		var row=color_table.insertRow(i);
		for(var j=0;j<21;j++)
		{
			var col="#";
			var text=document.createTextNode(" ");
			col+=color[index];			
			index++;
		 	row.insertCell(j);
			color_table.rows[i].cells[j].setAttribute("value",col);
			color_table.rows[i].cells[j].appendChild(text);
			color_table.rows[i].cells[j].style.backgroundColor=col;	
			color_table.rows[i].cells[j].style.cursor="hand";

			color_table.rows[i].cells[j].attachEvent("onclick",function(){var et_id=document.getElementById("et");et_id.focus();	document.execCommand('foreColor',false,event.srcElement.value);																																						 var div=document.getElementById("color_div_all");div.style.display="none";});
						
		}
	}
		div_color.attachEvent("onmouseout",function(){var img=document.getElementById("img2[1]");
			img.className="t2";var div=document.getElementById("color_div_all");div.style.display="none";});
		div_color.attachEvent("onmouseover",function(){var img=document.getElementById("img2[1]");img.className="t1"; var div=document.getElementById("color_div_all");div.style.display="block";});
	
	div_color.appendChild(color_table);	
	return div_color;
	
}

/*创建背景颜色*/

function create_bgcolor()
{	
	var div_color=document.createElement("div");
	
	div_color.setAttribute("id","div_color");
	
	var color_table=document.createElement("table");
	
	
	color_table.setAttribute("border","1px");
	color_table.setAttribute("width","250");
	color_table.setAttribute("height","150");
	color_table.setAttribute("cellSpacing","0");
	color_table.setAttribute("cellPadding","0");
	color_table.className="table_color";
	
	div_color.className="div_bgcolor";
	
	//div_color.offsetTop=84px;
	//div_color.offsetLeft="99";
	var index=0;
	
	for(var i=0;i<12;i++)
	{
		var row=color_table.insertRow(i);
		for(var j=0;j<21;j++)
		{
			var col="#";
			var text=document.createTextNode(" ");
			col+=color[index];			
			index++;
		 	row.insertCell(j);
			color_table.rows[i].cells[j].setAttribute("value",col);
			color_table.rows[i].cells[j].appendChild(text);
			color_table.rows[i].cells[j].style.backgroundColor=col;	
			color_table.rows[i].cells[j].style.cursor="hand";
			
			color_table.rows[i].cells[j].attachEvent("onclick",function(){var et_id=document.getElementById("et");et_id.focus();	document.execCommand('BackColor',false,event.srcElement.value);																																						 var div=document.getElementById("bg_color_div_all");div.style.display="none";});

		}
	}
	div_color.attachEvent("onmouseout",function(){var img=document.getElementById("img2[2]");
			img.className="t2";var div=document.getElementById("bg_color_div_all");div.style.display="none";});
		div_color.attachEvent("onmouseover",function(){var img=document.getElementById("img2[2]");img.className="t1"; var div=document.getElementById("bg_color_div_all");div.style.display="block";});
	div_color.appendChild(color_table);	
	return div_color;
	
}

/*上传图片*/

function create_insertImge()
{
	var insert_img=document.createElement("Div");
	var div_text=document.createElement("div");
	var text=document.createTextNode("插入图片");	
	div_text.appendChild(text);
	insert_img.className="div_img";
//	var form=document.createElement("form");
	var img_table=document.createElement("table");
	
	var tr=new Array();	
	for(var i=0;i<3;i++)
	{
		tr[i]=img_table.insertRow(i);	
    }
	tr[0].insertCell(0);
	tr[0].insertCell(1);
	tr[1].insertCell(0);
	tr[2].insertCell(0);
	tr[2].insertCell(1);
	
	var text=document.createTextNode("电脑上的图片");
	img_table.rows[0].cells[0].appendChild(text);
	
	var text=document.createTextNode("使用网络图片(URI)");
	img_table.rows[0].cells[1].appendChild(text);
	
	var file=document.createElement("input");
	file.setAttribute("type","file");
	file.setAttribute("id","InputFile");
	img_table.rows[1].cells[0].appendChild(file);
	img_table.rows[1].cells[0].setAttribute("width","50px");	
	
	
	var bt1=document.createElement("input");
	bt1.setAttribute("type","button");
	bt1.setAttribute("value","上传图片");
	img_table.rows[2].cells[1].appendChild(bt1);
	bt1.attachEvent("onclick",function(){bt_click(file.value);});
	
	var fr=document.createElement("iframe");
	fr.setAttribute("name","iframe1");
	fr.setAttribute("id","iframe1");
	
	var form=document.createElement("form");
	form.setAttribute("name","form1");
	form.setAttribute("id","form");
	form.setAttribute("method","POST");
	form.setAttribute("enctype","multipart/form-data");
	form.setAttribute("action","UpDeal.asp");
	form.appendChild(fr);
	
	insert_img.appendChild(form);
	//insert_img.appendChild(fr);
	insert_img.appendChild(div_text);
	insert_img.appendChild(img_table);
	insert_img.attachEvent("onmouseout",function(){var img=document.getElementById("img2[15]");
			img.className="t2";var div=document.getElementById("div_img");div.style.display="none";});
	insert_img.attachEvent("onmouseover",function(){var img=document.getElementById("img2[15]");
			img.className="t1";var div=document.getElementById("div_img");div.style.display="block";});
	return insert_img;
}


var ajax;
function create_ajax()
{
	
	try
	{
		ajax=new XMLHttpRequest();	
	}
	catch(a)
	{
		try
		{
			ajax=new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(b)
		{
			try
			{
				ajax=new ActiveXOject("Msxml2.XMLHTTP");	
			}
			catch(c)
			{
				alert("Create ajax fail");	
			}/*try three*/
		}/*try two*/
	}/*try first*/
	return ajax;
}

function bt_click(str)
{
	
	
	/*create_ajax()
   
	ajax.onreadystatechange=function()
	{
		if(ajax.readystate==4)
		{
			if(ajax.status==200)
			{	
			alert(ajax.responseText);
				
			}
			else
			{
				
				alert(ajax.readystate);
				alert(ajax.status);
			}			
		}		
	}
	
	ajax.open("post","FileLoad/Default.aspx");	
	ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	// var file_obj=new ActiveXObject("Scripting.FileSystemObject");

	 
	 var msg="data="+str;
	//var msg="file="+str;
	//ajax.open("get","FileLoad/Default.aspx?"+msg);
	
	ajax.send(msg);*/
	form.submit();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -