?? editorfunction.js
字號:
var htmlModeFlag = false;
function InitDocument()
{
editContent.document.designMode = "On";
editContent.document.open();
editContent.document.write('<html><head><meta http-equiv=Content-Type content="text/html; charset=gb2312"></head><body></body></html>');
editContent.document.close();
}
function doCommand(comm,value)
{
if(comm == "copy" && editContent.document.selection.createRange().text == "")
{
alert("請選擇你想復(fù)制的文字!");
return;
}
if (value == null || value == "")
editContent.document.execCommand(comm);
else
editContent.document.execCommand(comm,"",value);
editContent.focus();
}
function doCommandAfterCheck(comm,value)
{
if(!checkHtmlMode())
return;
else
doCommand(comm,value);
}
function htmlMode(flag)
{
if(flag)
{
var cont = editContent.document.body.innerHTML;
editContent.document.body.innerText = cont;
htmlModeFlag = true;
}
else
{
var cont = editContent.document.body.innerText;
editContent.document.body.innerHTML = cont;
htmlModeFlag = false;
}
}
function insertLink()
{
if (!checkHtmlMode())
return;
if(editContent.document.selection.createRange().text == "")
{
alert("請選擇要作為超鏈接的文字!");
return;
}
editContent.document.execCommand('CreateLink');
htmlModeFlag = false;
editContent.focus();
}
function insertImage()
{
var arr = showModalDialog("ImageUploadForm.jsp", window, "dialogWidth:420px;dialogHeight:160px;status:no;");
if(arr != null)
editContent.document.execCommand('InsertImage','',arr);
editContent.focus();
return;
}
function checkHtmlMode()
{
if(!htmlModeFlag)
return true;
alert("請取消“使用HTML方式編輯”!");
editContent.focus();
return false;
}
//字體加粗
function strongFont()
{
if(!checkHtmlMode())
return;
if(editContent.document.selection.createRange().text == "")
{
alert("請選擇要加粗的文字!");
return;
}
editContent.document.execCommand("bold");
editContent.focus();
}
//字體斜體
function italicFont()
{
if(!checkHtmlMode())
return;
if(editContent.document.selection.createRange().text == "")
{
alert("請選擇要使用斜體的文字!");
return;
}
editContent.document.execCommand("italic");
editContent.focus();
}
//左對齊
function alignLeft()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("justifyleft");
editContent.focus();
}
//居中對齊
function alignCenter()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("justifycenter");
editContent.focus();
}
//右對齊
function alignRight()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("justifyright");
editContent.focus();
}
//編號
function insertOrderList()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("insertorderedlist");
editContent.focus();
}
//項目符號
function insertUnorderList()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("insertunorderedlist");
editContent.focus();
}
//減少縮進(jìn)
function outDent()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("outdent");
editContent.focus();
}
//增加縮進(jìn)
function inDent()
{
if(!checkHtmlMode())
return;
editContent.document.execCommand("indent");
editContent.focus();
}
//字體顏色
function setColor()
{
if(!checkHtmlMode())
return;
if(editContent.document.selection.createRange().text == "")
{
alert("請選擇要設(shè)置顏色的文字!");
return;
}
var arr = showModalDialog("editorFiles/color.htm", "", "dialogWidth:18.5em; dialogHeight:17em; status:0");
if (arr != null)
editContent.document.execCommand("forecolor","",arr);
else
editContent.focus();
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -