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

📄 ubbhtml.js

📁 本论坛开发环境:jdk1.5+Tomcat5.5.17+sql server2000+Windows 2000 1、支持HTML内容编辑,支持网络贴图与附件上传等,支持多种版面风格. 2、论坛
💻 JS
字号:
document.writeln("<table width=98% height=100% cellpadding=2 cellspacing=0><tr><td align=left>");

//var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 removeFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|插入超链接 createLink|去掉超链接 unlink|"
var FormatTextlist="粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 removeFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|插入超链接 createLink|去掉超链接 unlink"
var list= FormatTextlist.split ('|');
for(i=0;i<list.length;i++) {
if (list[i]=="<br>"){document.write("<br>");
}else{
var TextName= list[i].split (' '); 
document.write(" <img align=absmiddle src=../htmledit/wbTextBox/images/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\" onClick=FormatText('"+TextName[1]+"')> ");
}
}

document.writeln("<img src=../htmledit/wbTextBox/images/fbcolor.gif alt=\"突出颜色\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\" onClick=BackColor()>");
document.writeln("<img src=../htmledit/wbTextBox/images/fgcolor.gif alt=\"字体颜色\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=foreColor()>");
document.writeln("<img src=../htmledit/wbTextBox/images/replace.gif alt=\"替换\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=replace()>");
document.writeln("<img src=../htmledit/wbTextBox/images/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onClick=img()>");
//document.writeln("<img alt=\"插入FLASH文件\" src=../htmledit/wbTextBox/images/swf.gif align=absmiddle style=cursor:hand onclick=flash()>");
document.writeln("<img alt=\"插入Media Player文件\" src=../htmledit/wbTextBox/images/wmv.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=MediaPlayer()>");
//document.writeln("<img alt=\"插入RealPlayer文件\" src=../htmledit/wbTextBox/images/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()>");
document.writeln("<img alt=\"插入表情\" src=../htmledit/wbTextBox/images/em.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=em()>");
document.writeln("<img alt=\"清理代码\" src=../htmledit/wbTextBox/images/cleancode.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=CleanCode()>");
document.writeln("<img alt=\"在线帮助\" src=../htmledit/wbTextBox/images/Help.gif align=absmiddle style=cursor:hand align=center onmouseover=\"this.style.borderWidth='1pt';this.style.borderColor='#000000';this.style.borderStyle='solid'\" style=\"BORDER-RIGHT: white 1pt solid; BORDER-TOP: white 1pt solid; BORDER-LEFT: white 1pt solid; BORDER-BOTTOM: white 1pt solid\" onmouseout=\"this.style.borderWidth='1pt';this.style.borderColor='white';\"  onclick=help()>");
document.writeln("</td></tr><tr><td height=100%><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe></td></tr><tr></tr></table>");

if (document.all){var IframeID=frames["HtmlEditor"];}else{var IframeID=document.getElementById("HtmlEditor").contentWindow;}
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"}
IframeID.document.open();
IframeID.document.write ('<script>i=0;function ctrlenterkey(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.form1.remenu.value=document.body.innerHTML;parent.document.form1.submit();parent.document.form1.submit1.disabled=true;}}<\/script><body onkeydown=ctrlenterkey()>');
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("remenu").value;
IframeID.document.body.style.fontSize="10pt";


function em(){
var arr = showModalDialog("../htmledit/inc/Emotion.htm", "", "dialogWidth:18em; dialogHeight:11em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function CleanCode(){
var body = IframeID.document.body;
var html = IframeID.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>");
IframeID.document.body.innerHTML = html;
}


function FormatText(command,option){IframeID.focus();IframeID.document.execCommand(command,true,option);}

function CheckLength(){alert("最大字符为 "+5000000+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}

function DoTitle(addTitle) {
var revisedTitle;var currentTitle = document.form1.topic.value;revisedTitle = addTitle+currentTitle;document.form1.topic.value=revisedTitle;document.form1.topic.focus();
}

function CheckForm(form){
form.remenu.value=IframeID.document.body.innerHTML; 
MessageLength=IframeID.document.body.innerHTML.length;
copyText1(form.remenu); //新增复制内容到剪贴板中
if(MessageLength<2){alert("文章内容不能小于2个字符!");return false;}
if(MessageLength>5000000){alert("文章内容不能超过5000000个字符!");return false;}
document.form1.submit1.disabled = true;
}
//以下新加
function copyText1(obj) {
	clipboardData.setData('Text',obj.value);
}
//以上新加

function yinyong(obj) {
	IframeID.document.body.innerHTML="[quote]"+obj+"[/quote]";
	IframeID.focus();
}

function Gopreview()
{
document.preview.remenu.value=IframeID.document.body.innerHTML; 
window.open('', 'preview_page', 'resizable,scrollbars,width=750,height=450');
document.preview.submit()
}

function BackColor()
{
  var arr = showModalDialog("../htmledit/inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
  if (arr != null) FormatText('BackColor', arr);
  else IframeID.focus();
}

function foreColor()
{
  var arr = showModalDialog("../htmledit/inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
  if (arr != null) FormatText('forecolor', arr);
  else IframeID.focus();
}

//////替换内容
function replace()
{
  var arr = showModalDialog("../htmledit/inc/replace.html", "", "dialogWidth:22em;dialogHeight:10em;status:0;help:0");
	if (arr != null){
		var ss;
		ss = arr.split("*")
		a = ss[0];
		b = ss[1];
		i = ss[2];
		con = IframeID.document.body.innerHTML;
		if (i == 1)
		{
			con = Ftbbs_code(con,a,b,true);
		}else{
			con = Ftbbs_code(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function Ftbbs_code(s,a,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); 
}
//////替换内容结束

function img(){
url=prompt("请输入图片文件URL地址:","http://");
if(!url || url=="http://") return;
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src="+url+" border=0 resize=1 vspace=5>");
}

function RealPlay(){
var arr = showModalDialog("../htmledit/inc/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function MediaPlayer(){
var arr = showModalDialog("../htmledit/inc/MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function flash(){
var arr = showModalDialog("../htmledit/inc/flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}

function help()
{
	var arr=showModalDialog("../htmledit/inc/help.html",window, "dialogWidth:23em; dialogHeight:11em; status:0; help:0");
}

⌨️ 快捷键说明

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