📄 text.js
字号:
function fnToolBar ()
{
var path="../images/";
var buttons = new Array (8,23,23,23,4,23,23,4,23,23,23,4,23,23,23,25);
var action = new Array ("","bold","italic","underline","","small","big","","justifyleft","justifycenter","justifyright","","insertorderedlist","insertunorderedlist","outdent","indent");
var tooltip = new Array ("","加粗","倾斜","下划线","","减小字号","增大字号","","左对齐","居中","右对齐","","编号","项目符号","减少缩进量","增加缩进量");
var left = 0,s = "";
for (var i=0; i<buttons.length; i++) {s += "<span oncontextmenu='return false' ondragstart='return false' style='width: " + buttons[i] + "; position: relative; height: 26'><span style='width: "+buttons[i]+"; clip:rect(0 "+buttons[i]+" 26 "+0+"); position: absolute; margin: 0px; padding: 0; height: 26; top: 0; left: 0; overflow: hidden'><img border=0 src="+path+"mytoolbar.gif style='position:absolute; top:0; left:-" + left + "' width=298 height=52 onMouseOver='this.style.top=-26' onMouseOut='this.style.top=0' onClick=\"format('"+action[i]+"',''); this.style.top=0\" title='"+tooltip[i]+"'></span></span>";
left += buttons[i];}
document.write (s);
}
function posts(){
msg = EditCtrl.document.body.innerHTML;
document.form1.Content.value = msg;
document.form1.submit()
}
function selectRange(){
EditCtrl.focus();
edit = EditCtrl.document.selection.createRange();
RangeType = EditCtrl.document.selection.type;
}
function format (what,opt) {
selectRange ();
if (what == "newmsg" && confirm ("新建文档原来的内容将删除,确定要新建吗?新建文档前建议先保存文档。")) {
EditCtrl.document.body.innerHTML = '';
}
else if (what == "saveas") {
var wst = document.form1.title.value;
if (wst == "") {
wst = "No Title";
}
var winSave = window.open();
var wd = winSave.document;
wd.open ();
wd.write (css1);
wd.write (EditCtrl.document.body.innerHTML);
wd.write (css2);
wd.close ();
wd.execCommand ("SaveAs","",wst);
winSave.close ();
}
else if (what == "table") {
var tables = showModalDialog (path+"table.htm", "", "dialogWidth:23.6em; dialogHeight:11.3em; status:0");
if (tables != null) {
edit.pasteHTML (tables);
}
}
else if (what == "small" || what == "big") {
var strHTML;
if (RangeType == "Text"){
edittxt = "<"+what+">"+edit.text+"</"+what+">";
edit.pasteHTML (edittxt);
}
}
else if (what == "pic") {
if (RangeType == "Control") {
EditCtrl.document.execCommand("InsertImage",true);
}
else {
var images = showModalDialog (path+"pic.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0");
if (images != null) {
edit.pasteHTML (images);
}
}
}
else if (what == "link") {
EditCtrl.document.execCommand("CreateLink",true);
}
else if (opt == "") {
if (what == "ForeColor") {
opt = prompt("请您定义所选取的文字的颜色。","");
}
else if (what == "FontName") {
opt = prompt("请您定义所选取的文字的字体。","");
}
else {
EditCtrl.document.execCommand (what);
}
}
if (opt != "" && opt != null && what != "saveas") {
EditCtrl.document.execCommand (what,"",opt);
}
EditCtrl.focus ();
}
function initEditor ()
{
EditCtrl.document.designMode="On";
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -