📄 htmledit.asp
字号:
<%
''================== *** 系统模块 *** ====================''
'' ''
'' 出品:内蒙古阿拉善左旗 马政永 ''
'' ''
'' [ 版权所有 侵权必究] ''
'' ''
'' 作者:马政永 QQ:651630318 ''
'' E_mail: mzymcm@yahoo.com.cn ''
'' ''
'' 版本:v2.0 ''
'' ''
'' 修订时间:2007.07.15 ''
'' ''
'' ''
''========================================================''
''========================================================''
''= 在线HTML编辑器单独运行模块 =''
''= 模块关键字:MZYHTMLEDIT =''
''========================================================''
Option Explicit
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
DIM MZYHTMLEDIT_YPIC,SHOWMTPATH,MZYHTMLUPPICO,SYSDB_connstr
MZYHTMLEDIT_YPIC = "./ICOCOLLECT.gif" ''' 本编辑器的ICO图标文件路径
SHOWMTPATH = "htmledit.asp?job=show&dm=" ''' 显示数据库中媒体的执行程序及路径
MZYHTMLUPPICO = "./cw.png" ''' 上传图片窗口初始化图片
SYSDB_connstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("mzyedit.mdb") & ";Jet OLEDB:Database Password=;"
DIM Job
Job=Request("job")
if (Job="htmledit") OR (Job="") then call MZYHTMLEDIT_win() ''' Go:模块ID:001[HTML编辑器总窗口]
if (Job="upload") then call MZYHTMLEDIT_upload() ''' Go:模块ID:002[上传文件模块]
if (Job="show") then call MZYHTMLEDIT_download() ''' Go:模块ID:003[下载文件模块]
if (Job="list") then call MZYHTMLEDIT_upList() ''' Go:模块ID:004[上传文件列表选择]
''===============================================================================''
''= 模块ID:001[HTML编辑器总窗口] MZYHTMLEDIT_win() =''
''===============================================================================''
Function MZYHTMLEDIT_win()
Response.Cookies("MZYHTMLEDIT") ="MZYHTMLEDIT"
Response.Cookies("MZYHTMLEDIT").Expires =Now+10000
Response.Cookies("MZYHTMLEDIT").Domain =Request("SERVER_NAME")
Response.Cookies("MZYHTMLEDIT").Path =Readsyspath(2)
Response.Cookies("MZYHTMLEDIT").Secure =FALSE
Response.Cookies("MZYHTMLEDIT")("USERCODE") =CodeCookie(GetMyTimeNumber(0))
Response.Write "<html>" & vbCrlf
Response.Write "<head>" & vbCrlf
Response.Write "<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" />" & vbCrlf
Response.Write "<title>htmledit</title>"
Response.Write "<style>" & vbCrlf
Response.Write "body {padding: 0;margin: 0;}" & vbCrlf
Response.Write "#edit_menubox{position: relative; left: 0px; top: 0px; width: 100%;z-index: 0; background-color:#F0F0E3; border: 1px solid #009999; padding: 2px;}" & vbCrlf
Response.Write ".tyys_a{border: 1 solid #009999;padding: 0;margin-top:0px;margin-right:1px;margin-bottom:2px;margin-left:0px;width:22px;height:22px;background-position: center top;background-image: url(" & MZYHTMLEDIT_YPIC & ");background-repeat: no-repeat;font-family: 宋体; font-size: 0px;}" & vbCrlf
Response.Write ".tyys_b{font-family: 宋体;color: #000000;font-size:12px;cursor:default;margin-bottom:2px;}" & vbCrlf
Response.Write "</style>" & vbCrlf
Response.Write "</head>"
Response.Write "<body>"
Response.Write "<div style='position: absolute;z-index:998; background-color:#F7F7EA; display:none;' id='waitlayer1' name='waitlayer1'></div>"
Response.Write "<div style='border:1px solid #808000; padding:2px; overflow-x:auto;overflow-y:auto;position: absolute;z-index:998; background-color:#F7F7EA;display:none;' id='menulayer1' name='menulayer1'></div>"
Response.Write "<table border='0' width='100%' height='100%' cellspacing='0' cellpadding='0' OnMouseOver='ycmenu();' style='z-index:0;'><tr><td height='0%'>"
Response.Write "<div id='edit_menubox'>" & vbCrlf
Response.Write "<input type='button' id='fgx' class='tyys_a' style='background-position: -10px -820px;border: 0px;width:4px;'>"
Response.Write "<input type='button' id='newopen' OnClick='clearhtml();' class='tyys_a' title='清空新建' style='background-position: 0px 0px;' >"
Response.Write "<input type='button' id='viewok' OnClick='viewhtml();' class='tyys_a' title='显示预览' style='background-position: 0px -40px;' >"
Response.Write "<input type='button' id='Undo' OnClick='doatv(this.id);' class='tyys_a' title='撤消' style='background-position: 0px -60px;' >"
Response.Write "<input type='button' id='Redo' OnClick='doatv(this.id);' class='tyys_a' title='恢复' style='background-position: 0px -80px;' >"
Response.Write "<input type='button' id='Delete' OnClick='doatv(this.id);' class='tyys_a' title='删除' style='background-position: 0px -100px;' >"
Response.Write "<input type='button' id='Cut' OnClick='doatv(this.id);' class='tyys_a' title='剪切' style='background-position: 0px -120px;'>"
Response.Write "<input type='button' id='Copy' OnClick='doatv(this.id);' class='tyys_a' title='复制' style='background-position: 0px -140px;'>"
Response.Write "<input type='button' id='Paste' OnClick='doatv(this.id);' class='tyys_a' title='粘贴' style='background-position: 0px -160px;'>"
Response.Write "<input type='button' id='Object' OnMouseDown='mkmidiwin(this.id,event);' class='tyys_a' title='插入物件' style='background-position: 0px -180px;'>"
Response.Write "<input type='button' id='Table' OnMouseDown='mktabwin(this.id,event);' class='tyys_a' title='插入表格' style='background-position: 0px -200px;'>"
Response.Write "<input type='button' id='Layer' class='tyys_a' OnClick='incOle(this.id,this.id);' title='插入层' style='background-position: 0px -220px;'>"
Response.Write "<input type='button' id='Picture' OnMouseDown='mkimgupwin(this.id,event);' class='tyys_a' title='加入图片' style='background-position: 0px -240px;'>"
Response.Write "<input type='button' id='fgx' class='tyys_a' style='background-position: -10px -820px;border: 0px;width:4px;'>"
Response.Write "<input type='button' id='CreateLink' OnClick='doatv(this.id);' class='tyys_a' title='加超链' style='background-position: 0px -260px;'>"
Response.Write "<input type='button' id='Unlink' OnClick='doatv(this.id);' class='tyys_a' title='取消超链' style='background-position: 0px -280px;'>"
Response.Write "<input type='button' id='fgx' class='tyys_a' style='background-position: -10px -820px;border: 0px;width:4px;'>"
Response.Write "<input type='button' id='Bold' OnClick='doatv(this.id);' class='tyys_a' title='加粗' style='background-position: 0px -300px;'>"
Response.Write "<input type='button' id='Italic' OnClick='doatv(this.id);' class='tyys_a' title='斜体' style='background-position: 0px -320px;'>"
Response.Write "<input type='button' id='Underline' OnClick='doatv(this.id);' class='tyys_a' title='下划线' style='background-position: 0px -340px;'>"
Response.Write "<input type='button' id='JustifyLeft' OnClick='doatv(this.id);' class='tyys_a' title='距左' style='background-position: 0px -360px;'>"
Response.Write "<input type='button' id='JustifyCenter' OnClick='doatv(this.id);' class='tyys_a' title='距中' style='background-position: 0px -380px;'>"
Response.Write "<input type='button' id='JustifyRight' OnClick='doatv(this.id);' class='tyys_a' title='距右' style='background-position: 0px -400px;'>"
Response.Write "<input type='button' id='Justify' OnClick='doatv(JustifyLeft.id);' class='tyys_a' title='分散' style='background-position: 0px -420px;'>"
Response.Write "<input type='button' id='InsertOrderedList' OnClick='doatv(this.id);' class='tyys_a' title='数字标识' style='background-position: 0px -440px;'>"
Response.Write "<input type='button' id='InsertUnorderedList' OnClick='doatv(this.id);' class='tyys_a' title='点标识' style='background-position: 0px -460px;'>"
Response.Write "<input type='button' id='Indent' OnClick='doatv(this.id);' class='tyys_a' title='缩进' style='background-position: 0px -480px;'>"
Response.Write "<input type='button' id='Outdent' OnClick='doatv(this.id);' class='tyys_a' title='取消缩进' style='background-position: 0px -500px;'>"
Response.Write "<input type='button' id='BackColor' OnMouseDown='selcolor(this.id,event);' class='tyys_a' title='字背景色' style='background-position: 0px -520px;'>"
Response.Write "<input type='button' id='ForeColor' OnMouseDown='selcolor(this.id,event);' class='tyys_a' title='字体颜色' style='background-position: 0px -540px;'>"
Response.Write "<input type='button' id='fgx' class='tyys_a' style='background-position: -10px -820px;border: 0px;width:4px;'>"
Response.Write "<input type='button' id='RemoveFormat' OnClick='doatv(this.id);' class='tyys_a' title='取消格式' style='background-position: 0px -560px;'>"
Response.Write "<input type='button' id='wordtot' class='tyys_a' OnClick='cleanWord();' title='除Word格式' style='background-position: 0px -580px;'>"
Response.Write "<input type='button' id='InsertHorizontalRule' OnClick='doatv(this.id);' class='tyys_a' title='水平线' style='background-position: 0px -600px;'>"
Response.Write "<input type='button' id='Rollcapt' class='tyys_a' OnClick='incOle(this.id,this.id);' title='滚动字幕' style='background-position: 0px -620px;'>"
Response.Write "<input type='button' id='Calendar' class='tyys_a' OnClick='inCalendar();'title='插入日期' style='background-position: 0px -640px;'>"
Response.Write "<input type='button' id='fgx' class='tyys_a' style='background-position: -10px -820px;border: 0px;width:4px;'>"
Response.Write "<input type='button' id='Wspace' class='tyys_a' OnClick='chWspace();' title='调整字距' style='background-position: 0px -660px;'>"
Response.Write "<input type='button' id='Lspace' class='tyys_a' OnClick='chLspace();' title='调整行距' style='background-position: 0px -680px;'>"
Response.Write "<input type='button' id='Inexcel' class='tyys_a' OnClick='incOle(this.id,this.id);' title='插入Excel' style='background-position: 0px -700px;'>"
Response.Write "<input type='button' id='Infj' OnMouseDown='mksubbrupwin(this.id,event);' class='tyys_a' title='插入附件' style='background-position: 0px -720px;'>"
Response.Write "<input type='button' id='Tohtml' class='tyys_a' title='查看源码' OnClick='htot(this.id);' style='background-position: 0px -740px;'>"
Response.Write "<SELECT NAME='FontName' ID='FontName' class='tyys_b' ONCHANGE='if(this.selectedIndex!=0){dobtv(this.name,this[this.selectedIndex].value);}'>"
Response.Write "<OPTION SELECTED style='color:#7C845E;'>选择字体</OPTION><OPTION VALUE='宋体'>宋体</OPTION><OPTION VALUE='黑体'>黑体</OPTION>"
Response.Write "<OPTION VALUE='楷体_GB2312'>楷体</OPTION><OPTION VALUE='Arial'>Arial</OPTION><OPTION VALUE='Arial Black'>Arial Black</OPTION>"
Response.Write "<OPTION VALUE='Wingdings'>Wingdings</OPTION></SELECT>"
Response.Write "<SELECT NAME='FontSize' ID='FontSize' class='tyys_b' ONCHANGE='if(this.selectedIndex!=0){selfontsize(this.name,this[this.selectedIndex].value);}'>"
Response.Write "<OPTION SELECTED style='color:#7C845E;'>选择字号</OPTION><OPTION VALUE='10'>五号字</OPTION>"
Response.Write "<OPTION VALUE='12'>四号字</OPTION><OPTION VALUE='18'>三号字</OPTION><OPTION VALUE='26'>二号字</OPTION>"
Response.Write "<OPTION VALUE='40'>一号字</OPTION></SELECT></div></td></tr><tr><td height='100%'>"
Response.Write "<IFRAME id='MZYEDITWINDOW' name='MZYEDITWINDOW' id='MZYEDITWINDOW' frameBorder='1' scrolling='auto' src='' width='100%' height='100%' onFocus=""ycolediv('waitlayer1');""></IFRAME>"
Response.Write "</td></tr></table><input type='hidden' name='hiddeninputnr' id='hiddeninputnr'></body>" & vbCrlf
Response.Write "<SCRIPT language='javascript'>" & vbCrlf
Response.Write "// MZYStudio 超小在线HTML编辑器,欢迎大家一起分享,请保留原创痕迹,保留本人的信息谢谢!" & vbCrlf
Response.Write "// 编程制作:马政永 Email:mzymcm@yahoo.com.cn 内蒙古阿拉善盟左旗" & vbCrlf
Response.Write "var Htmlmode='Y';" & vbCrlf
Response.Write "var nrdivid=0;" & vbCrlf
Response.Write "var opmenumc='';" & vbCrlf
Response.Write "var xmlHttp;" & vbCrlf
Response.Write "var editor;var vmdownobjmc;var vjX;var vjY;" & vbCrlf
Response.Write "editor = document.getElementById('MZYEDITWINDOW').contentWindow;" & vbCrlf
Response.Write "editor.document.open();" & vbCrlf
Response.Write "editor.document.writeln('<html><head>');" & vbCrlf
Response.Write "editor.document.writeln('</head><body></body></html>');" & vbCrlf
Response.Write "editor.document.close();" & vbCrlf
Response.Write "editor.document.designMode = 'On';" & vbCrlf
Response.Write "editor.document.contentEditable = true;" & vbCrlf
Response.Write "editor.document.charset='gb2312';" & vbCrlf
Response.Write "editor.document.body.style.fontSize='12px';" & vbCrlf
Response.Write "editor.document.body.style.lineHeight='14px';" & vbCrlf
Response.Write " function clearhtml()// 新建内容" & vbCrlf
Response.Write " {if(editor.document.body.innerHTML==''){alert('文件已经是空白状态')}else{if(confirm('清除所有正在编辑的网页内容?')){editor.document.body.innerHTML=''}}}" & vbCrlf
Response.Write " function viewhtml()// 预览内容" & vbCrlf
Response.Write " {if(editor.document.body.innerHTML!=''){var viewhtmlwin=window.open ('','viewhtmlwin','height=200,width=200,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=yes,location=no, status=no');viewhtmlwin.document.open();viewhtmlwin.focus();viewhtmlwin.document.write(editor.document.body.innerHTML);viewhtmlwin.document.close();}}" & vbCrlf
Response.Write " function doatv(atname)// 执行操作A" & vbCrlf
Response.Write " {editor.focus();" & vbCrlf
Response.Write " if (window.navigator.userAgent.indexOf('MSIE')>=1){" & vbCrlf
Response.Write " editor.document.execCommand(atname);" & vbCrlf
Response.Write " }else{" & vbCrlf
Response.Write " if (atname=='CreateLink'){var tourltxt = prompt('请录入URL', 'http://');editor.document.execCommand(atname,false,tourltxt);}else{" & vbCrlf
Response.Write " editor.document.execCommand(atname,'','');}" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " function dobtv(atname,jobtxt)// 执行操作B" & vbCrlf
Response.Write " {editor.focus();" & vbCrlf
Response.Write " if (window.navigator.userAgent.indexOf('MSIE')>=1){" & vbCrlf
Response.Write " editor.document.execCommand(atname,false,jobtxt);" & vbCrlf
Response.Write " }else{" & vbCrlf
Response.Write " editor.document.execCommand(atname,'',jobtxt);" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " function htot(atname)//-- 模式切换" & vbCrlf
Response.Write " {if (Htmlmode=='N'){" & vbCrlf
Response.Write " if (window.navigator.userAgent.indexOf('MSIE')>=1){" & vbCrlf
Response.Write " editor.document.body.innerHTML=editor.document.body.innerText;" & vbCrlf
Response.Write " }else{" & vbCrlf
Response.Write " editor.document.body.innerHTML=editor.document.body.textContent;" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " Htmlmode='Y';GetId(atname).title='查看源码';GetId(atname).style.backgroundPosition='0px -740px';}else{" & vbCrlf
Response.Write " if (window.navigator.userAgent.indexOf('MSIE')>=1){" & vbCrlf
Response.Write " editor.document.body.innerText=editor.document.body.innerHTML;" & vbCrlf
Response.Write " }else{" & vbCrlf
Response.Write " editor.document.body.textContent=editor.document.body.innerHTML;" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " Htmlmode='N';GetId(atname).title='返回编辑状态';GetId(atname).style.backgroundPosition='0px -760px';}editor.focus();}" & vbCrlf
Response.Write " function incOle(atname,olenr)//-- 插入物件" & vbCrlf
Response.Write " {nrdivid=nrdivid+1;" & vbCrlf
Response.Write " //-- 插入字幕" & vbCrlf
Response.Write " if (atname=='Rollcapt'){var Rollcapttxt='<marquee bgcolor=#E7E7DC scrollamount=1>双击这添加内容';olenr=Rollcapttxt+'</marquee>';}" & vbCrlf
Response.Write " //-- 插入附件" & vbCrlf
Response.Write " if (atname=='Infj'){var layertxt='<a target=\'_blank\' href=\''+ olenr + '\' style=\'font-family: 宋体; font-size: 12px; color: #003399; font-weight: bold; text-decoration: none; border: 1px groove #C0C0C0; padding: 2px; background-color: #F4F4EC\'>◆ 点这里下载附件 ◆</a>';olenr=layertxt;}" & vbCrlf
Response.Write " //-- 插入图片" & vbCrlf
Response.Write " if (atname=='Picture'){var layertxt='<img border=\'0\' src=\''+ olenr + '\' hspace=\'2\' vspace=\'2\'>';olenr=layertxt;}" & vbCrlf
Response.Write " //-- 插入层" & vbCrlf
Response.Write " if (atname=='Layer'){var layertxt='<div style=\'width:200;height:200;background-color:#F7F9E3;overflow:scroll;\' id=div'+nrdivid+'>双击这添加内容</div>';olenr=layertxt;}" & vbCrlf
Response.Write " //-- 插入Excel控件" & vbCrlf
Response.Write " if (atname=='Inexcel'){var Rollcapttxt='<OBJECT id=Spreadsheet1 codeBase=file:\Bobsoftwareoffice2000msowc.cab height=250 width=100% classid=clsid:0002E510-0000-0000-C000-000000000046></OBJECT>';olenr=Rollcapttxt;}" & vbCrlf
Response.Write " if ((olenr!='') && (Htmlmode=='Y')){editor.focus();crerantohtml(olenr);}" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " function selfontsize(atname,sizemc)//-- 选择字号" & vbCrlf
Response.Write " {" & vbCrlf
Response.Write " editor.focus();var selxxtxt='';selxxtxt=gtselectnrxx();" & vbCrlf
Response.Write " selxxtxt = selxxtxt.replace(/<\/?SPAN[^>]*>/gi, '' );" & vbCrlf
Response.Write " var newxtxt='<span style=\'font-size:'+sizemc+'px\'>'+selxxtxt+'</span>';" & vbCrlf
Response.Write " if (Htmlmode=='Y') {editor.focus();crerantohtml(newxtxt);}" & vbCrlf
Response.Write " }" & vbCrlf
Response.Write " function cleanWord() {" & vbCrlf
Response.Write " if (Htmlmode=='Y'){" & vbCrlf
Response.Write " if(confirm('您是否要清除WORD格式?')){" & vbCrlf
Response.Write " html=editor.document.body.innerHTML;" & vbCrlf
Response.Write " html = html.replace(/<\/?SPAN[^>]*>/gi, '' );" & vbCrlf
Response.Write " html = html.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, '<$1$3') ;" & vbCrlf
Response.Write " html = html.replace(/<(\w[^>]*) style='([^']*)'([^>]*)/gi, '<$1$3') ;" & vbCrlf
Response.Write " html = html.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, '<$1$3') ;" & vbCrlf
Response.Write " html = html.replace(/<\\?\?xml[^>]*>/gi, '') ;" & vbCrlf
Response.Write " html = html.replace(/<\/?\w+:[^>]*>/gi, '') ;" & vbCrlf
Response.Write " html = html.replace(/ /, ' ' );" & vbCrlf
Response.Write " var re = new RegExp('(<P)([^>]*>.*?)(<\/P>)','gi');" & vbCrlf
Response.Write " html = html.replace( re, '<div$2</div>' ) ;" & vbCrlf
Response.Write " editor.document.body.innerHTML=html;}}" & vbCrlf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -