?? 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 + -