📄 edit.html
字号:
<HTML><HEAD><TITLE>editor</TITLE>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<STYLE>
SELECT {FONT: 12px "Verdana,Arial"}
.toolbar {MARGIN-BOTTOM: 0pt; OVERFLOW: hidden; HEIGHT: 28px}
.mode LABEL {FONT: bold 12px "Verdana,Arial"}
.mode .current {COLOR: darkgreen}
.heading { COLOR: #006600}
</STYLE>
<SCRIPT>
var bLoad=false,public_description=new Editor
function Editor() {
this.put_html=put_html;
this.get_html=get_html;
this.testHTML=testHTML
this.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
}
else
return idEdit.document.all[0].innerText;
}
function put_html(sVal) {
if (bMode)
idEdit.document.all[0].innerHTML=sVal
else
idEdit.document.all[0].innerText=sVal
}
var sHeader="<body STYLE=\"font-size: 12px;\">"
var sFooter="</body>"
bMode=true
sel=null
function displayError() {alert("查看源代码的模式下,此功能不能使用!");idEdit.focus()}
function format(what,opt) {
if (!bMode) {
displayError()
return
}
if (opt=="removeFormat"){
what=opt;opt=null
}
if (opt=="CustomFont")
opt = prompt("请输入字体代码?","Geneva, Arial, Sans-Serif")
if ((opt=="") && (what=="forecolor"))
opt = prompt("请输入颜色代码?","#000000")
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:\/\/www.matrix3.com.cn\/)",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 IMAGESelect(picurl) {
if (!bMode) {
displayError()
return
}
var isIMG = getEl("IMG",idEdit.document.selection.createRange().parentElement())
if ((picurl!=null) && (!isIMG)){
idEdit.focus()
var sel=idEdit.document.selection.createRange()
sel.pasteHTML("<img id='zoom' src=\""+picurl+"\">")
sel.select()
}
else
idEdit.focus()
}
function clearEdit(){
setMode(false)
mH.checked=true;
idEdit.document.open();
idEdit.document.write(sHeader)
idEdit.document.write(sFooter)
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
idEdit.document.open()
idEdit.document.write(sHeader)
idEdit.document.write(sContents)
idEdit.document.write(sFooter)
idEdit.document.close()
}
else {
var sContents=idEdit.document.all.tags("BODY")[0].innerHTML
if (sContents.length==82){sContents="";}
idEdit.document.open()
idEdit.document.write(sHeader)
idEdit.document.write(sFooter)
idEdit.document.close()
idEdit.document.body.innerText=sContents
}
bMode=bNewMode
}
modeA.className=bMode?"current":"";modeB.className=bMode?"":"current"
idEdit.focus()
}
</SCRIPT>
<SCRIPT event=DocumentComplete() for=EditCtrl>
bLoad=true
</SCRIPT>
<script language="JavaScript">
function ow_forInner(src,win_width,win_height)
{
window.open(src,'','width='+win_width+',height='+win_height+',resizable=no,scrollbars=no,status=no,toolbar=no,menubar=no,location=no');
}
</script>
</head>
<BODY onselectstart="return false" onload=doLoad() leftmargin="5" topmargin="5" marginwidth="0" marginheight="0">
<SPAN id=idBox style="VISIBILITY: hidden; WIDTH: 100%; TEXT-ALIGN: center">
<TABLE class=toolbar align=left cellPadding=0 cellSpacing=2 id=tb1>
<TBODY>
<TR>
<TD id=htmlOnly vAlign=center noWrap>
<SELECT onchange="format('fontname',this[this.selectedIndex].value);this.selectedIndex=0">
<OPTION class=heading selected>字体
<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">
<OPTION class=heading selected>字号<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">
<OPTION class=heading selected>颜色
<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>
<TABLE class=toolbar align=left cellPadding=0 cellSpacing=2>
<TBODY>
<TR>
<TD id=htmlOnly vAlign=center noWrap><SPAN class=mode id=tb3>
<input id=mW onClick=setMode(true) type=radio checked name=rMode><LABEL onclick=setMode(true) class=current id=modeA
for=mw>编辑</LABEL>
<INPUT id=mH onclick=setMode(false)
type=radio name=rMode><LABEL id=modeB for=mH onclick=setMode(false)>源代码</LABEL>
</SPAN> </TD>
</TR></TBODY></TABLE>
<SPAN class=toolbar onselectstart="return false" id=tb2 ondragstart="return false">
<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='LINE-HEIGHT: 18px;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 align=absmiddle BORDER=0 SRC='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) {
if (bWhichEditor)
idEdit = EditCtrl.DOM.parentWindow
else {
EditCtrl.document.designMode="On"
idEdit = EditCtrl
}
idEdit.document.open()
idEdit.document.write("")
idEdit.document.close()
}
function doLoad() {
idBox.style.visibility=''
initEditor(false)
bLoad=true;
idEdit.document.open();
idEdit.document.write(sHeader)
idEdit.document.write(sFooter)
idEdit.document.close();
idEdit.focus()
}
document.write("<IFRAME NAME=EditCtrl marginwidth=3 frameborder=1 WIDTH=100% height=305></IFRAME>")
</SCRIPT>
<SCRIPT>
window.onresize = rew
function rew()
{
document.frames.EditCtrl.height=document.body.offsetHeight-45;
}
</SCRIPT></SPAN></SPAN></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -