点击回首页
我的浏览记录 | | 帮助?
当前位置:
首页>> 留言本类>> Asp.net多模式留言系统>> 源文件浏览
[免费版 Free] WebForm,下载次数:4779 次 | 关键字: Access 多功能编辑器 留言板 论坛

源码截图

源码目录树

当前路径:dxtb/editor.js     var Editor_edit;	//selectRang
var Editor_RangeType;
var Editor_selection;
var Editor_filterScript = true;
var Editor_charset="UTF-8";
var Editor_bLoad=false;
var Editor_pureText=true;
var Editor_bTextMode=1;		//默认为Design模式

//预览
function Editor_InitDocument(hiddenid, charset)
{	
	if (charset!=null)
	Editor_charset=charset;
	if (Editor_bIsIE5){
		var Editor_bodyTag="<style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" title=\"Ctrl+Enter直接提交贴子\">";
	}else
	{
		var Editor_bodyTag="<style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\">";
	}
	
	if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){
	IframeID.document.designMode="On"
	}
	IframeID.document.open();
	IframeID.document.write ('<html><head><link type=text/css rel=stylesheet href=css/style.css>');
	IframeID.document.write(Editor_bodyTag);
	IframeID.document.write("</body>");
	IframeID.document.write("</html>");
	IframeID.document.close();
	IframeID.document.body.contentEditable = "True";
	IframeID.document.charset=Editor_charset;
	Editor_bLoad=true;
	Editor_setStyle();
}

function Editor_setMode(n)
{
	Editor_setStyle();
	var cont;
	var Editor_Toolbar0=document.getElementById("ExtToolbar0");
	var Editor_Toolbar1=document.getElementById("ExtToolbar1");
	var Editor_Toolbar2=document.getElementById("ExtToolbar2");
	switch (n){
		case 1:
				Editor_Toolbar0.style.display="";
				Editor_Toolbar1.style.display="";
				Editor_Toolbar2.style.display="";
				if (document.getElementById("Editor_TabHtml").className=="Editor_TabOn"){
					if (Editor_bIsIE5){
						cont=IframeID.document.body.innerText;
						cont=Editor_correctUrl(cont);
						if (Editor_filterScript)
						cont=Editor_FilterScript(cont);
						IframeID.document.body.innerHTML=cont;
					}else{
						var html = IframeID.document.body.ownerDocument.createRange();
						html.selectNodeContents(IframeID.document.body);
						IframeID.document.body.innerHTML = html.toString();
					}
				}
				break;
		case 2:
				if (canusehtml=="1" || canusehtml=="3")
				{
					Editor_Toolbar0.style.display="none";	//关闭工具栏
					Editor_Toolbar1.style.display="none";
					Editor_Toolbar2.style.display="none";
					Editor_cleanHtml();
					cont=IframeID.document.body.innerHTML;
					cont=Editor_correctUrl(cont);
					if (Editor_filterScript){cont=Editor_FilterScript(cont);}
					if (Editor_bIsIE5){					//IE
						IframeID.document.body.innerText=cont;
					}else{								//Nc
						var html=document.createTextNode(cont);
						IframeID.document.body.innerHTML = "";
						IframeID.document.body.appendChild(html);
					}
				}else{
				alert("您不能使用这个功能!")
				}
				break;
	}
	Editor_setTab(n);
	Editor_bTextMode=n
}

function Editor_setTab(n)
{
	//html和design按钮的样式更改
	var mhtml=document.getElementById("Editor_TabHtml");
	var mdesign=document.getElementById("Editor_TabDesign");
	if (n==1)
	{
		mhtml.className="Editor_TabOff";
		mdesign.className="Editor_TabOn";
	}
	else if (n==2)
	{
		mhtml.className="Editor_TabOn";
		mdesign.className="Editor_TabOff";
	}
	else if (n==3)
	{
		mhtml.className="Editor_TabOff";
		mdesign.className="Editor_TabOff";
	}
}

function Editor_setStyle()
{
	//var bs = IframeID.document.body.runtimeStyle;
	var bs = IframeID.document.body.style;
	//根据mode设置iframe样式表	
	if (Editor_bTextMode==2) {
		bs.fontFamily="Arial";
		bs.fontSize="10pt";
	}else{
		bs.fontFamily="Arial";
		bs.fontSize="10.5pt";
	}
	bs.scrollbar3dLightColor= '#D4D0C8';
	bs.scrollbarArrowColor= '#000000';
	bs.scrollbarBaseColor= '#D4D0C8';
	bs.scrollbarDarkShadowColor= '#D4D0C8';
	bs.scrollbarFaceColor= '#D4D0C8';
	bs.scrollbarHighlightColor= '#808080';
	bs.scrollbarShadowColor= '#808080';
	bs.scrollbarTrackColor= '#D4D0C8';
	bs.border='0';
}

function Editor_validateMode()
{
	if (Editor_bTextMode!=2) return true;
	alert("请取消“查看HTML源代码”选项再使用系统编辑功能或者提交!");
	IframeID.focus();
	return false;
}

function Editor_CleanCode()
{
	var editor=IframeID;
	editor.focus();
	if (Editor_bIsIE5){
	// 0bject based cleaning
		var body = editor.document.body;
		for (var index = 0; index < body.all.length; index++) {
			tag = body.all[index];
		//*if (tag.Attribute["className"].indexOf("mso") > -1)
			tag.removeAttribute("className","",0);
			tag.removeAttribute("style","",0);
		}
	// Regex based cleaning
		var html = editor.document.body.innerHTML;
		html = html.replace(/\<p>/gi,"[$p]");
		html = html.replace(/\<\/p>/gi,"[$\/p]");
		html = html.replace(/\<br>/gi,"[$br]");
		html = html.replace(/\<[^>]*>/g,"");        ///过滤其它所有"<...>"标签
		html = html.replace(/\[\$p\]/gi,"<p>");
		html = html.replace(/\[\$\/p\]/gi,"<\/p>");
		html = html.replace(/\[\$br\]/gi,"<br>");
		editor.document.body.innerHTML = html;
	}else
	{
		var html = IframeID.document.body.ownerDocument.createRange();
		html.selectNodeContents(IframeID.document.body);
		IframeID.document.body.innerHTML = html.toString();
	}
}

function Editor_ChekEmptyCode(html)
{
	html = html.replace(/\<[^>]*>/g,"");        ///过滤其它所有"<...>"标签
	html = html.replace(/&nbsp;/gi, "");
	html = html.replace(/o:/gi, "");
	html = html.replace(/\s/gi, "");
	return html;
}

var colour
function FormatText(command, option)
{
var codewrite
if (Editor_bIsIE5){
		if (option=="removeFormat"){
		command=option;
		option=null;}
		IframeID.focus();
	  	IframeID.document.execCommand(command, false, option);
		Editor_pureText = false;
		IframeID.focus();
		
}else{
		if ((command == 'forecolor') || (command == 'backcolor')) {
			parent.command = command;
			buttonElement = document.getElementById(command);
			IframeID.focus();
			document.getElementById("colourPalette").style.left = getOffsetLeft(buttonElement) + "px";
			document.getElementById("colourPalette").style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
		
			if (document.getElementById("colourPalette").style.visibility=="hidden")
				{document.getElementById("colourPalette").style.visibility="visible";
			}else {
				document.getElementById("colourPalette").style.visibility="hidden";
			}
		
			//get current selected range
			var sel = IframeID.document.selection; 
			if (sel != null) {
				colour = sel.createRange();
			}
		}
		else{
		IframeID.focus();
	  	IframeID.document.execCommand(command, false, option);
		Editor_pureText = false;
		IframeID.focus();
		}
	}

}

function setColor(color)
{
	IframeID.focus();
	IframeID.document.execCommand(parent.command, false, color);
	IframeID.focus();
	document.getElementById("colourPalette").style.visibility="hidden";
}

//----------------
function Editor_FilterScript(content)
{
	content = Editor_rCode(content, 'javascript:', '<b>javascript</b> :');
	var RegExp = /<script[^>]*>(.*)<\/script>/gi;
	content = content.replace(RegExp, "<div class=HtmlCode>&lt;!-- Script 代码开始 --&gt;<br>$1<br>&lt;!-- Script 代码结束 --&gt;</div>");
	RegExp = /<P>&nbsp;<\/P>/gi;
	content = content.replace(RegExp, "");
	return content;
}

function Editor_rCode(s,a,b,i){
	//s原字串,a要换掉pattern,b换成字串,i是否区分大小写
	a = a.replace("?","\\?");
	if (i==null)
	{
		var r = new RegExp(a,"gi");
	}else if (i) {
		var r = new RegExp(a,"g");
	}
	else{
		var r = new RegExp(a,"gi");
	}
	return s.replace(r,b); 
}
//Editor_InitDocument("Body","GB2312");
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途) 企业QQ:2852517674
地址:北京市海淀区中关村鼎好大厦A座二层 邮编:100080
Room A-801,Dinghao Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2015. 京ICP备09089570号 | 京公网安备11010702000869号
分享该页面
关闭侧边栏