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

📄 post.js

📁 海洋分类信网程序是由海洋城市设计工作室基于ASP+Access/Mssql技术开发的分类信息程序
💻 JS
📖 第 1 页 / 共 2 页
字号:
var sCurrMode
StyleEditorHeader = "<style>BLOCKQUOTE {BORDER-RIGHT: #cccccc 1px dotted; PADDING-RIGHT: 4px; BORDER-TOP: #cccccc 1px dotted; PADDING-LEFT: 4px; PADDING-BOTTOM: 4px; MARGIN: 16px; BORDER-LEFT: #cccccc 1px dotted; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px dotted}</style><script>i=0;function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.form.content.value=document.body.innerHTML;parent.document.form.submit();parent.document.form.EditSubmit.disabled=true;}}<\/script><body onkeydown=ctlent()>" ;


// 根据浏览器类型选择编辑器
if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) {
// IE浏览器
YBBFont="<option value='宋体'>宋体</option> <option value='黑体'>黑体</option> <option value='仿宋_GB2312'>仿宋_GB2312</option> <option value='楷体_GB2312'>楷体_GB2312</option> <option value='隶书'>隶书</option> <option value='幼圆'>幼圆</option> <option value='新宋体'>新宋体</option><option value='Arial'>Arial</option><option value='Courier New'>Courier New</option><option value='Garamond'>Garamond</option><option value='Georgia'>Georgia</option><option value='Tahoma'>Tahoma</option><option value='Times New Roman'>Times</option><option value='Verdana'>Verdana</option>"
document.write("<table width=100% height=100% cellpadding=2 cellspacing=0><tr id=EditButton style=DISPLAY:block><td align=left colspan=6>");
document.write("<select onChange=\"FormatText('FormatBlock',this[this.selectedIndex].value);this.selectedIndex=0;\"><option>段落</option><option value=\"&lt;P&gt;\">正文</option><option value=\"&lt;H1&gt;\">标题一</option><option value=\"&lt;H2&gt;\">标题二</option><option value=\"&lt;H3&gt;\">标题三</option><option value=\"&lt;H4&gt;\">标题四</option><option value=\"&lt;H5&gt;\">标题五</option><option value=\"&lt;H6&gt;\">标题六</option><option value=\"&lt;PRE&gt;\">预设格式</option></select> ");
document.write("<select onChange=\"FormatText('fontname',this[this.selectedIndex].value);this.selectedIndex=0;\"><option>字体</option>"+YBBFont+"</select> ");
document.write("<select onChange=\"FormatText('fontsize',this[this.selectedIndex].value);this.selectedIndex=0;\"><option>大小</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> ");
document.write("<img src=images/ybb/fgcolor.gif title=\"字体颜色\" align=absmiddle style=cursor:hand onClick=foreColor()>");
document.write("<img src=images/ybb/fbcolor.gif title=\"突出显示\" align=absmiddle style=cursor:hand onClick=BackColor()>");
document.write("<img src=images/ybb/InsertImage.gif title=\"插入图片\" align=absmiddle style=cursor:hand onClick=InsertImage()>");
document.write("<img title=\"插入 FLASH、MediaPlayer、RealPlayer 文件\" src=images/ybb/mp.gif align=absmiddle style=cursor:hand onclick=MediaPlayer()>");
document.write("<img src=images/ybb/replace.gif title=\"替换\" align=absmiddle style=cursor:hand onClick=replace()>");
document.write("<img title=\"插入表情\" src=images/ybb/em.gif align=absmiddle style=cursor:hand onclick=em()>");
document.write("<img src=images/ybb/specialchar.gif title=\"插入特殊字符\" align=absmiddle style=cursor:hand onClick=specialchar()>");
document.write('<img src="images/ybb/insertdate.gif" title=\"插入今天的日期\" align=absmiddle border="0" style=cursor:hand onClick=insertdate()>');
document.write('<img src="images/ybb/inserttime.gif" title=\"插入当前的时间\" align=absmiddle border="0" style=cursor:hand onClick=inserttime()>');
document.write('<img src="images/ybb/Break.gif" title=\"换行符\" align=absmiddle border="0" style=cursor:hand onClick=Break()>');

var FormatTextlist="插入输入框 InsertInputText|插入文字输入区 InsertTextArea|插入单选钮 InsertInputRadio|插入复选框 InsertInputCheckbox|插入下拉框 InsertSelectDropdown|插入按钮 InsertButton|<br>|粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|两端对齐 justifyfull|编号 insertorderedlist|项目符号 InsertUnorderedList|减少缩进量 Outdent|增加缩进量 indent|普通水平线 InsertHorizontalRule|段落 InsertParagraph|全选 selectAll|取消选择 unselect|删除当前选中区 Delete|剪切 cut|复制 copy|粘贴 paste|撤消 undo|恢复 redo|插入超链接 createLink|去掉超链接 Unlink|打印 Print"
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 width=20 height=20 src=images/ybb/"+TextName[1]+".gif title="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')>");
}
}
document.write("<img title=\"清洁代码\" src=images/ybb/Cleanup.gif align=absmiddle style=cursor:hand onclick=CleanCode()>");
document.write("</td></tr><tr><td height=100% colspan=6><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe></td></tr>");
document.write("<tr><td></div><table border=0 cellpadding=0 cellspacing=0 height=20>");
document.write("<tr>");
document.write("<td width=5></td>");
document.write("<td class=StatusBarBtnON id=HtmlEditor_EDIT onclick=setMode('EDIT')><img border=0 src=images/ybb/modeedit.gif align=absmiddle></td>");
document.write("<td width=5></td>");
document.write("<td class=StatusBarBtnOff id=HtmlEditor_CODE onclick=setMode('CODE')><img border=0 src=images/ybb/modecode.gif align=absmiddle></td>");
document.write("<td width=5></td>");
document.write("<td class=StatusBarBtnOff id=HtmlEditor_VIEW onclick=setMode('VIEW')><img border=0 src=images/ybb/modepreview.gif width=50 height=15 align=absmiddle></td>");
document.write("<td width=5></td>");
document.write("<td align=right width=100%><img border=0 src=images/ybb/+.gif align=absmiddle onclick=sizeChange(100) style=cursor:pointer title='增大编辑区'><img border=0 src=images/ybb/-.gif align=absmiddle onclick=sizeChange(-100) style=cursor:pointer title='减小编辑区'></td>");
document.write("</tr></table>");
document.write("</td></tr></table>");

}else{
// 其他浏览器
document.write ('<iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe>')
}


var IframeID=document.getElementById("HtmlEditor").contentWindow;
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"} //可编辑与StyleEditorHeader生效
IframeID.document.open();
IframeID.document.write(StyleEditorHeader+document.form.content.value);
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.style.fontSize="10pt";

// 预览
function Preview()
{
if(IframeID.document.body.innerHTML<1){alert("请输入内容后才能预览!");return false;}
window.open('', 'preview_page', 'resizable,scrollbars,width=750,height=450');
document.preview.content.value=IframeID.document.body.innerHTML; 
document.preview.submit()
}

// 调整编辑器的大小
function sizeChange(size){
	var obj=document.getElementById("HtmlEditor");
	obj.height = (parseInt(obj.offsetHeight) + size);
	if (parseInt(obj.offsetHeight)< 200 ){obj.height ="100%"}
}

// 设置编辑器的内容
function setHTML(html) {
	IframeID.document.body.innerHTML = html;
	switch (sCurrMode){
	case "EDIT":
		HtmlEditor.document.open();
		HtmlEditor.document.write(StyleEditorHeader+html);
		HtmlEditor.document.close();
		HtmlEditor.document.body.contentEditable="true";
		EditButton.style.display = 'block';
                break;
	case "CODE":
		HtmlEditor.document.open();
		HtmlEditor.document.write(html);
		HtmlEditor.document.close();
		HtmlEditor.document.body.innerText=html;
		HtmlEditor.document.body.contentEditable="true";
		EditButton.style.display = 'none';
                break;
	case "VIEW":
		HtmlEditor.document.open();
		HtmlEditor.document.write(StyleEditorHeader+html);
		HtmlEditor.document.close();
		HtmlEditor.document.body.contentEditable="false";
		EditButton.style.display = 'none';
		break;
	}
}

// 改变模式:代码、编辑、预览
function setMode(NewMode){
	if (NewMode!=sCurrMode){
		switch(sCurrMode){
		case "EDIT":
			sBody = HtmlEditor.document.body.innerHTML;
			break;
		case "CODE":
			sBody = HtmlEditor.document.body.innerText;
			break;
		case "VIEW":
			sBody = HtmlEditor.document.body.innerHTML;
			break;
		default:
			sBody = IframeID.document.body.innerHTML;
			break;
		}
		// 换图片
		try{
			document.all["HtmlEditor_CODE"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_EDIT"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_VIEW"].className = "StatusBarBtnOff";
			document.all["HtmlEditor_"+NewMode].className = "StatusBarBtnOn";
			}
		catch(e){
			}
		sCurrMode = NewMode;
		setHTML(sBody);
		
	}
}
// 取编辑器的内容
function getHTML() {
	var html;
	if(sCurrMode=="CODE"){
		html = IframeID.document.body.innerText;
	}else{
		html = IframeID.document.body.innerHTML;
	}
	return html;
}


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

function addcontent(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML(""+theSmilie+"");
}

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

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

function emoticon(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=images/Emotions/"+theSmilie+".gif>");
}


function CheckForm(form){
if(sCurrMode=="CODE"){alert("编辑器处于代码状态下不能发送内容!");return false;}
if(document.form.Subject.value.length<2){alert("标题不能小于2个字符!");return false;}
form.content.value = getHTML();
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<2){alert("内容不能小于2个字符!");return false;}

⌨️ 快捷键说明

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