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

📄 reedit.js

📁 与asp相关的技术 如数据库和网页设计 很有用的哦
💻 JS
字号:
//--------------------------------------------------------------
var editMode=true;//true为编辑模式,false为HTML模式
var imgIndex=1;//用于记录上传的图片的个数
//实现各种字的格式,比如粗体、斜体、居中、居右、居左等
function F(com,para){
	if (editMode)
	{
		content.focus();
		content.document.execCommand(com,true,para);
	}
	return;
}
//实现按钮效果
	function butt(objbutt,state){
		if (editMode)
		{	
			if(state==1) 
				objbutt.className ="buttUp";
			else if(state==2) 
				objbutt.className ="buttDown" ;
			else 
				objbutt.className ="buttNone";
		}
		return;
	}
//实现添加超级链接
	function CreateLink(){
		if (editMode)
		{
			content.focus();
			var selectRange = content.document.selection.createRange();   //获得输入的内容
			selectRange.execCommand("CreateLink");
		}
		return;
	}
//插入表格
	function InsertTable(){
		if (editMode)
		{
			content.focus();
			var selectRange= content.document.selection.createRange();
			var tableInfor=window.showModalDialog("showTable.asp","","dialogWidth=340px;dialogHeight=150px;status=0");
			selectRange.pasteHTML(tableInfor);
		}
		return;
	}
//插入图片
	function InsertImg(){
		if (editMode)
		{
			content.focus();
			//定义弹出框的大小和位置
			var ImagePageWidth="370";
			var ImagePageHeight="130";
			var popleft=((document.body.clientWidth - ImagePageWidth) / 2)+window.screenLeft;
			var poptop=(((document.body.clientHeight -ImagePageHeight) / 2))+window.screenTop-40;	
			window.open("upload_form.asp","NewWindow","scrollbars=NO,width=" + ImagePageWidth + ",height=" + ImagePageHeight + ",left=" + popleft + ",top=" + poptop);	
		}
		return;
	}

//显示颜色对话框
function ShowColor(c){
	return window.showModalDialog("showColor.asp",c,"dialogWidth=300px;dialogHeight=300px;status=0");
}
//设置背景色
function SetBackColor(){
	if (editMode)
	{
		var bgColor=ShowColor();
		if(bgColor && bgColor!=""){
			F('BackColor',bgColor);
		}
	}
}
//设置字体颜色
function SetForeColor(){
	if (editMode)
	{
		var fColor=ShowColor();
		if(fColor && fColor!=""){
			F('ForeColor',fColor);
		}
	}
}
//---------------------------------------------------------
//切换编辑方式
	function setMode(isHTML)
	{
		editMode=!isHTML;
		var cont;
		if (isHTML) {
			cont=content.document.body.innerHTML;
			content.document.body.innerText=cont;
		} 
		else {
			cont=content.document.body.innerText;
			content.document.body.innerHTML=cont;
		}
		content.focus();
	}

//--------------------------------------------------------------
function document.onreadystatechange(){// 当文档完全调入时,进行初始化
	//写入body的属性
	content.document.open()
	content.document.write("<html><head></head><BODY bgcolor=#ffffff MARGINHEIGHT=1 MARGINWIDTH=1>" + form1.body.value + "</body></html>");
	content.document.close()
	//设置该界面可写
	content.document.designMode="On"
	content.focus();
	//content.Select();
	return;
}

//生成HTML文件
	function MySave(){
		//下面获得iframe中的HTML源代码
		var data;
		if (editMode)
		{
			data=content.document.body.innerHTML;
		}
		else
		{
			data=content.document.body.innerText;
		}
		//赋值给隐藏的文本框,并提交表单
		form1.body.value=data;                //网页内容
		form1.submit();                       //提交表单
	}

⌨️ 快捷键说明

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