editor.htm
来自「ASP编写的一个公司网站的源程序」· HTM 代码 · 共 293 行
HTM
293 行
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0034)http://xqnweb.myrice.com/dream.htm -->
<HTML>
<HEAD>
<TITLE>Wayou's WebEdit Tool</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=gb2312">
<STYLE>SELECT {
BACKGROUND: #cccccc; FONT: 12px "Verdana,Arial"
}
.toolbar {
BORDER-RIGHT: black 1px solid; BORDER-TOP: black 1px solid; BACKGROUND: lightgrey; MARGIN-BOTTOM: 3pt; OVERFLOW: hidden; BORDER-LEFT: black 1px solid; BORDER-BOTTOM: black 1px solid; HEIGHT: 28px
}
.mode LABEL {
FONT: bold 12px "Verdana,Arial"
}
.mode .current {
COLOR: darkgreen
}
.heading {
BACKGROUND: lightgrey; COLOR: #006600
}
</STYLE>
<SCRIPT>var bLoad=false,public_description=new Editorfunction Editor() {this.put_html=put_html;this.get_html=get_html;this.testHTML=testHTMLthis.bReady = false}function cleanupHTML() { bodyTags=idEdit.document.all[0].all, i for (i=bodyTags.tags("FONT").length-1;i >= 0;i--) if (bodyTags.tags("FONT")[i].style.backgroundColor="#ffffff") { bodyTags.tags("FONT")[i].style.backgroundColor="" if (bodyTags.tags("FONT")[i].outerHTML.substring(0,6)=="<FONT>") bodyTags.tags("FONT")[i].outerHTML=bodyTags.tags("FONT")[i].innerHTML }}function testHTML(bAllowHead,extras) { mW.click() var badStuff=new Array("F15"),headStuff=new Array("AK47"),hasStuff=new Array(),bodyTags=idEdit.document.body.all,i=0 for (i=0;i<badStuff.length;i++) if (bodyTags.tags(badStuff[i]).length>0) hasStuff[hasStuff.length]=badStuff[i] if (!bAllowHead) for (i=0;i<headStuff.length;i++) if (bodyTags.tags(headStuff[i]).length>0) hasStuff[hasStuff.length]=headStuff[i] if (extras!=null) for (i=0;i<extras.length;i++) if (bodyTags.tags(extras[i]).length>0) hasStuff[hasStuff.length]=extras[i] var str="" if (hasStuff.length>0) { str="Please remove the following HTML Tags from your message and resubmit:" for (i=0;i<hasStuff.length;i++) str+="\n "+hasStuff[i] str+= "\nRemember, when using HTML Mode you may need to escape \nthe brackets surrounding tags (< and >) with < and >" setTimeout("mH.click()",0) } return str}function get_html() {if (bMode) { cleanupHTML() return idEdit.document.all[0].innerHTML}elsereturn idEdit.document.all[0].innerText;}function put_html(sVal) {if (bMode)idEdit.document.all[0].innerHTML=sValelseidEdit.document.all[0].innerText=sVal}var sHeader="<link rel=\"stylesheet\" href=\"theme.css\"><BODY STYLE=\"font-family:Verdana; font-size: 12px; letter-spacing: 0px\">",bMode=true,sel=null//var sHeader="",bMode=true,sel=nullfunction displayError() {alert("Formatting toolbar is only accessible in WYSIWYG mode");idEdit.focus()}function format(what,opt) { if (!bMode) { displayError() return } if (opt=="removeFormat"){ what=opt;opt=null } if (opt=="CustomFont") opt = prompt("Format your text with what font face?","Geneva, Arial, Sans-Serif") if ((opt=="") && (what=="forecolor")) opt = prompt("Format your text with what color?","Black") if (bMode) { if (opt==null) idEdit.document.execCommand(what) else idEdit.document.execCommand(what,"",opt) var s=idEdit.document.selection.createRange(),p=s.parentElement() idEdit.focus() } sel=null}function getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement return start}function createLink() { if (!bMode) { displayError() return } var isA = getEl("A",idEdit.document.selection.createRange().parentElement()) var str=prompt("请输入你想连接到网址: (例如, http:\/\/wayou.126.com\/)",isA ? isA.href : "http:\/\/") if ((str!=null) && (str!="http://")) { if ((idEdit.document.selection.type=="None") && (!isA)) { var sel=idEdit.document.selection.createRange() sel.pasteHTML("<a onfocus=this.blur() HREF=\""+str+"\">"+str+"</A> ") sel.select() } else format("CreateLink",str) } else idEdit.focus()}//***************************************************function clearEdit(){setMode(false)mH.checked=true;idEdit.document.open();idEdit.document.write(sHeader)idEdit.document.close();}function selectAll(){setMode(false)idEdit.document.all[0].innerHTML.select();}//**************************************************function setMode(bNewMode) { if (bNewMode!=bMode) { if (bNewMode) { var sContents=idEdit.document.all[0].innerText //alert(sContents); idEdit.document.open() idEdit.document.write(sContents) idEdit.document.close() // alert(idEdit.document.all.tags("HTML")[0].innerHTML); // idEdit.document.all[0].outerHTML=sContents } else { //cleanupHTML() var sContents=idEdit.document.all.tags("HTML")[0].innerHTML // alert(sContents.length); if (sContents.length==82){sContents="";} idEdit.document.open() idEdit.document.write(sHeader) idEdit.document.close() idEdit.document.body.innerText=sContents } bMode=bNewMode for (var i=0;i<htmlOnly.children.length;i++) htmlOnly.children[i].disabled=(!bMode) } modeA.className=bMode?"current":"";modeB.className=bMode?"":"current" idEdit.focus()}</SCRIPT>
<SCRIPT event="DocumentComplete()" for="EditCtrl">/*if (!bLoad) { setTimeout("initEditor(true)",0) idBox.style.visibility='' idBox.focus()}*/bLoad=true</SCRIPT>
<META content="MSHTML 6.00.2600.0" name="GENERATOR">
</HEAD>
<BODY onselectstart="return false" style="PADDING-RIGHT: 2pt; PADDING-LEFT: 2pt; PADDING-BOTTOM: 2pt; MARGIN: 0pt; CURSOR: default; PADDING-TOP: 2pt" bgColor="#f7f7f7" onload="doLoad()">
<SPAN id="idBox" style="VISIBILITY: hidden; WIDTH: 100%; TEXT-ALIGN: center">
<TABLE class="toolbar" id="tb1" style="MARGIN-BOTTOM: 2pt; PADDING-TOP: 1pt" cellSpacing="2" cellPadding="0" align="left">
<TBODY>
<TR>
<TD id="htmlOnly" vAlign="center" noWrap><SELECT onchange="format('fontname',this[this.selectedIndex].value);this.selectedIndex=0" ID="Select1" NAME="Select1">
<OPTION class="heading" selected>
Font<OPTION value="geneva,arial,sans-serif">
Arial<OPTION value="verdana,geneva,arial,sans-serif">
Verdana<OPTION value="times,serif">
Times<OPTION value="courier, monospace">
Courier<OPTION style="COLOR: navy" value="CustomFont">Custom...</OPTION>
</SELECT>
<SELECT onchange="format('fontSize',this[this.selectedIndex].text);this.selectedIndex=0" ID="Select2" NAME="Select2">
<OPTION class="heading" selected>
Size<OPTION>
1<OPTION>
2<OPTION>
3<OPTION>
4<OPTION>
5<OPTION>
6<OPTION>7</OPTION>
</SELECT>
<SELECT onchange="format('forecolor',this[this.selectedIndex].style.color);this.selectedIndex=0" ID="Select3" NAME="Select3">
<OPTION class="heading" selected>
Color<OPTION style="COLOR: black">
Black<OPTION style="COLOR: gray">
Gray<OPTION style="COLOR: darkred">
Dark Red<OPTION style="COLOR: navy">
Navy<OPTION style="COLOR: darkgreen">
Dark Green<OPTION>Custom...</OPTION>
</SELECT>
</TD>
</TR>
</TBODY></TABLE>
<SPAN class="toolbar" onselectstart="return false" id="tb2" ondragstart="return false" style="WIDTH: 270px">
<SCRIPT event="ShowContextMenu(xPos, yPos)" for="EditCtrl">//important</SCRIPT>
<SCRIPT>var buttons=new Array(24,23,23,4,23,23,23,4,23,23,23,23,4,24),action=new Array("bold","italic","underline","","justifyleft","justifycenter","justifyright","","insertorderedlist","insertunorderedlist","outdent","indent","","createLink"),tooltip=new Array("粗体","斜体","下划线","","向左对齐","向中靠","向右对齐","","列表","取消列表","取消缩进","缩进","","生成网址"),left=0,s=""for (var i=0;i<buttons.length;i++) { s+="<SPAN STYLE='position:relative;height:26;width: " + buttons[i] + "'><SPAN STYLE='position:absolute;margin:0px;padding:0;height:26;top:0;left:0;width:" + (buttons[i]) + ";clip:rect(0 "+buttons[i]+" 25 "+0+");overflow:hidden'><IMG BORDER=0 SRC='/htmledit/images/toolbar.gif' STYLE='position:absolute;top:0;left:-" + left + "' WIDTH=267 HEIGHT=50" if (buttons[i]!=4) { s+=" onmouseover='this.style.top=-25' onmouseout='this.style.top=0' ONCLICK=\"" if (action[i]!="createLink") s+="format('" + action[i] + "');this.style.top=0\" " else s+="createLink();this.style.top=0\" " s+="TITLE=\"" + tooltip[i] + "\"" } s+="></SPAN></SPAN>" left+=buttons[i]}document.write(s + "</span>")function initEditor(bWhichEditor) { // IE5 Secret Sauce if (bWhichEditor) idEdit = EditCtrl.DOM.parentWindow else { EditCtrl.document.designMode="On" idEdit = EditCtrl } idEdit.document.open() idEdit.document.write("") idEdit.document.close()// alert(idEdit.document.all[0].tagName) //idEdit.document.all[0].innerHTML="" // idEdit.document.body.innerText=""// if (external.raiseEvent) external.raiseEvent("onready",window.event)}function doLoad() { idBox.style.visibility='' initEditor(false) bLoad=true; idEdit.focus() //alert(idEdit.document.all[0].tagName); //alert(idEdit.document.all[0].all.tags("FONT").length) } document.write("<IFRAME id=EditCtrl NAME=EditCtrl WIDTH=100%></IFRAME>")</SCRIPT>
<TABLE align="left" border="0" ID="Table1">
<TBODY>
<TR>
<TD align="left"><SPAN class="mode" id="tb3"><INPUT id="mW" onclick="setMode(true)" type="radio" CHECKED name="rMode" VALUE="mW">
<LABEL class="current" id="modeA" for="mw">编辑状态</LABEL>
<INPUT id="mH" onclick="setMode(false)" type="radio" name="rMode" VALUE="mH">
<LABEL id="modeB" for="mH">显示源代码</LABEL>
</SPAN>
</SPAN>
<SCRIPT> setTimeout("document.all.EditCtrl.style.height=document.body.offsetHeight-90",0) window.onresize = new Function("document.all.EditCtrl.style.height=document.body.offsetHeight-90")</SCRIPT>
</SPAN></TD></TR></TBODY></TABLE></SPAN></SPAN></BODY></HTML>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?