?? dhtmledit.js
字號:
var Newasp_edit; //selectRang
var Newasp_RangeType;
var Newasp_selection;
var Newasp_filterScript = true;
var Newasp_charset="UTF-8";
var Newasp_bLoad=false
var Newasp_pureText=true
var Newasp_bTextMode=1 //默認為Design模式
//預覽
function Newasp_InitDocument(hiddenid, charset)
{
if (charset!=null)
Newasp_charset=charset;
if (Newasp_bIsIE5){
var Newasp_bodyTag="<style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" title=\"Ctrl+Enter直接提交貼子\" onkeydown=\"ctlent();\">";
}else
{
var Newasp_bodyTag="<style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\">";
}
var h=document.getElementById(hiddenid).value;
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){
IframeID.document.designMode="On"
}
IframeID.document.open();
IframeID.document.write ('<html><head>');
if (Newasp_bIsIE5){
IframeID.document.write ('<script language="javascript">');
IframeID.document.write ('var ispost=0;');
IframeID.document.write (' function ctlent(eventobject)');
IframeID.document.write (' {');
IframeID.document.write (' if(event.ctrlKey && window.event.keyCode==13&&ispost==0)');
IframeID.document.write (' {');
IframeID.document.write (' ispost=1;');
IframeID.document.write (' parent.Newasp_CopyData("'+hiddenid+'"); ');
IframeID.document.write (' parent.document.myform.Submit.disabled=true;');
IframeID.document.write (' parent.document.myform.Submit2.disabled=true;');
IframeID.document.write (' parent.document.myform.submit();');
IframeID.document.write (' }');
IframeID.document.write (' }');
IframeID.document.write ('<\/script>');
}
IframeID.document.write(Newasp_bodyTag);
if (h!="")
{
h=Newasp_FilterScript(h);
IframeID.document.write(h);
}
IframeID.document.write("</body>");
IframeID.document.write("</html>");
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.charset=Newasp_charset;
Newasp_bLoad=true;
Newasp_setStyle();
IframeID.focus();
}
function Newasp_setMode(n)
{
Newasp_setStyle();
var cont;
var Newasp_Toolbar0=document.getElementById("ExtToolbar0");
var Newasp_Toolbar1=document.getElementById("ExtToolbar1");
var Newasp_Toolbar2=document.getElementById("ExtToolbar2");
var Newasp_Toolbar3=document.getElementById("old_Toolbars");
switch (n){
case 1:
Newasp_Toolbar0.style.display="";
Newasp_Toolbar1.style.display="";
Newasp_Toolbar2.style.display="";
Newasp_Toolbar3.style.display="none"; //ubb工具欄關閉
if (document.getElementById("Newasp_TabHtml").className=="Newasp_TabOn"){
if (Newasp_bIsIE5){
cont=IframeID.document.body.innerText;
cont=Newasp_correctUrl(cont);
if (Newasp_filterScript)
cont=Newasp_FilterScript(cont);
IframeID.document.body.innerHTML=cont;
}else{
var html = IframeID.document.body.ownerDocument.createRange();
html.selectNodeContents(IframeID.document.body);
IframeID.document.body.innerHTML = html.toString();
}
}
break;
case 2:
if (canusehtml=="1" || canusehtml=="3")
{
Newasp_Toolbar0.style.display="none"; //關閉工具欄
Newasp_Toolbar1.style.display="none";
Newasp_Toolbar2.style.display="none";
Newasp_Toolbar3.style.display="none"; //關閉UBB
Newasp_cleanHtml();
cont=IframeID.document.body.innerHTML;
cont=Newasp_correctUrl(cont);
if (Newasp_filterScript){cont=Newasp_FilterScript(cont);}
if (Newasp_bIsIE5){ //IE
IframeID.document.body.innerText=cont;
}else{ //Nc
var html=document.createTextNode(cont);
IframeID.document.body.innerHTML = "";
IframeID.document.body.appendChild(html);
}
}else{
alert("您不能使用這個功能!")
}
break;
case 3:
Newasp_Toolbar0.style.display="";
Newasp_Toolbar1.style.display="none";
Newasp_Toolbar2.style.display="none";
Newasp_Toolbar3.style.display="";
var mhtml=document.getElementById("Newasp_TabHtml");
var mdesign=document.getElementById("Newasp_TabDesign");
if (mhtml.className=="Newasp_TabOn")
{
if (Newasp_bIsIE5){
cont=IframeID.document.body.innerText;
cont=Newasp_correctUrl(cont);
if (Newasp_filterScript)
cont=Newasp_FilterScript(cont);
IframeID.document.body.innerHTML=cont;
}else{
var html = IframeID.document.body.ownerDocument.createRange();
html.selectNodeContents(IframeID.document.body);
IframeID.document.body.innerHTML = html.toString();
}
}
break;
}
Newasp_setTab(n);
Newasp_bTextMode=n
}
function Newasp_setTab(n)
{
//html和design按鈕的樣式更改
var mhtml=document.getElementById("Newasp_TabHtml");
var mdesign=document.getElementById("Newasp_TabDesign");
var mOldTool=document.getElementById("Newasp_TabOldTools");
if (n==1)
{
mhtml.className="Newasp_TabOff";
mdesign.className="Newasp_TabOn";
mOldTool.className="Newasp_TabOff";
}
else if (n==2)
{
mhtml.className="Newasp_TabOn";
mdesign.className="Newasp_TabOff";
mOldTool.className="Newasp_TabOff";
}
else if (n==3)
{
mhtml.className="Newasp_TabOff";
mdesign.className="Newasp_TabOff";
mOldTool.className="Newasp_TabOn";
}
}
function Newasp_setStyle()
{
//var bs = IframeID.document.body.runtimeStyle;
var bs = IframeID.document.body.style;
//根據mode設置iframe樣式表
if (Newasp_bTextMode==2) {
bs.fontFamily="Arial";
bs.fontSize="10pt";
}else{
bs.fontFamily="Arial";
bs.fontSize="10.5pt";
}
bs.scrollbar3dLightColor= '#D4D0C8';
bs.scrollbarArrowColor= '#000000';
bs.scrollbarBaseColor= '#D4D0C8';
bs.scrollbarDarkShadowColor= '#D4D0C8';
bs.scrollbarFaceColor= '#D4D0C8';
bs.scrollbarHighlightColor= '#808080';
bs.scrollbarShadowColor= '#808080';
bs.scrollbarTrackColor= '#D4D0C8';
bs.border='0';
}
function Newasp_validateMode()
{
if (Newasp_bTextMode!=2) return true;
alert("請取消“查看HTML源代碼”選項再使用系統編輯功能或者提交!");
IframeID.focus();
return false;
}
function Newasp_CleanCode()
{
var editor=IframeID;
editor.focus();
if (Newasp_bIsIE5){
// 0bject based cleaning
var body = editor.document.body;
for (var index = 0; index < body.all.length; index++) {
tag = body.all[index];
//*if (tag.Attribute["className"].indexOf("mso") > -1)
tag.removeAttribute("className","",0);
tag.removeAttribute("style","",0);
}
// Regex based cleaning
var html = editor.document.body.innerHTML;
html = html.replace(/\<p>/gi,"[$p]");
html = html.replace(/\<\/p>/gi,"[$\/p]");
html = html.replace(/\<br>/gi,"[$br]");
html = html.replace(/\<[^>]*>/g,""); ///過濾其它所有"<...>"標簽
html = html.replace(/\[\$p\]/gi,"<p>");
html = html.replace(/\[\$\/p\]/gi,"<\/p>");
html = html.replace(/\[\$br\]/gi,"<br>");
editor.document.body.innerHTML = html;
}else
{
var html = IframeID.document.body.ownerDocument.createRange();
html.selectNodeContents(IframeID.document.body);
IframeID.document.body.innerHTML = html.toString();
}
}
function Newasp_ChekEmptyCode(html)
{
html = html.replace(/\<[^>]*>/g,""); ///過濾其它所有"<...>"標簽
html = html.replace(/ /gi, "");
html = html.replace(/o:/gi, "");
html = html.replace(/\s/gi, "");
return html;
}
var colour
function FormatText(command, option)
{
var codewrite
if (Newasp_bIsIE5){
if (option=="removeFormat"){
command=option;
option=null;}
IframeID.focus();
IframeID.document.execCommand(command, false, option);
Newasp_pureText = false;
IframeID.focus();
}else{
if ((command == 'forecolor') || (command == 'backcolor')) {
parent.command = command;
buttonElement = document.getElementById(command);
IframeID.focus();
document.getElementById("colourPalette").style.left = getOffsetLeft(buttonElement) + "px";
document.getElementById("colourPalette").style.top = (getOffsetTop(buttonElement) + buttonElement.offsetHeight) + "px";
if (document.getElementById("colourPalette").style.visibility=="hidden")
{document.getElementById("colourPalette").style.visibility="visible";
}else {
document.getElementById("colourPalette").style.visibility="hidden";
}
//get current selected range
var sel = IframeID.document.selection;
if (sel != null) {
colour = sel.createRange();
}
}
else{
IframeID.focus();
IframeID.document.execCommand(command, false, option);
Newasp_pureText = false;
IframeID.focus();
}
}
}
function setColor(color)
{
IframeID.focus();
IframeID.document.execCommand(parent.command, false, color);
IframeID.focus();
document.getElementById("colourPalette").style.visibility="hidden";
}
//----------------
function Newasp_FilterScript(content)
{
content = Newasp_rCode(content, 'javascript:', '<b>javascript</b> :');
var RegExp = /<script[^>]*>(.*)<\/script>/gi;
content = content.replace(RegExp, "<div class=HtmlCode><!-- Script 代碼開始 --><br>$1<br><!-- Script 代碼結束 --></div>");
RegExp = /<P> <\/P>/gi;
content = content.replace(RegExp, "");
return content;
}
function Newasp_rCode(s,a,b,i){
//s原字串,a要換掉pattern,b換成字串,i是否區分大小寫
a = a.replace("?","\\?");
if (i==null)
{
var r = new RegExp(a,"gi");
}else if (i) {
var r = new RegExp(a,"g");
}
else{
var r = new RegExp(a,"gi");
}
return s.replace(r,b);
}
//Newasp_InitDocument("Body","GB2312");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -