📄 htmlarea.html
字号:
<!--
HTML Area Control
Created By Sameers (theAngrycodeR)
All Rights Reserved
Contact at theAngrycodeR@Yahoo.com
-->
<HTML>
<HEAD>
<title>HTML Area by Sameers </title>
</HEAD>
<body>
<STYLE>
.EditControl {
width:500px;
height:300px; }
.tblTable {
width : 500px;
height: 30px;
border:0;
cellspacing:0;
cellpadding:0;
background-color:#A78C5C;
}
.butClass {
width:22;
height:22;
border: 0px solid;
border-color: #D6D3CE ;
background-color:#A78C5C;
}
.tdClass {
padding-left: 0px;
padding-top:0px;
background-Color: #A78C5C; }
</STYLE>
<Script Language="javascript">
function doCommand(ctrl)
{
//BackColor
var mCommand, uInterface, vValue;
switch(ctrl.id)
{
case 'imgSuperScript' :
mCommand = 'superscript';
uInterface = false;
vValue = null;
break;
case 'imgSubScript' :
mCommand = 'subscript';
uInterface = false;
vValue = null;
break;
case 'imgBold' :
mCommand = 'bold';
uInterface = false;
vValue = null;
break;
case 'imgItalic' :
mCommand = 'italic';
uInterface = false;
vValue = null;
break;
case 'imgBoldItalic' :
doCommand (document.all['imgBold'])
doCommand (document.all['imgItalic'])
doCommand (document.all['imgUnderLine'])
break;
case 'imgUnderLine' :
mCommand = 'underline';
uInterface = false;
vValue = null;
break;
case 'imgStrikeThrough' :
mCommand = 'strikethrough';
uInterface = false;
vValue = null;
break;
case 'imgAlignLeft' :
mCommand = 'justifyleft';
uInterface = false;
vValue = null;
break;
case 'imgAlignRight' :
mCommand = 'justifyright';
uInterface = false;
vValue = null;
break;
case 'imgAlignCenter' :
mCommand = 'justifycenter';
uInterface = false;
vValue = null;
break;
case 'imgAlignJustify' :
mCommand = 'justifyfull';
uInterface = false;
vValue = null;
break;
case 'imgCut' :
mCommand = 'cut';
uInterface = false;
vValue = null;
break;
case 'imgCopy' :
mCommand = 'copy';
uInterface = false;
vValue = null;
break;
case 'imgPaste' :
mCommand = 'paste';
uInterface = false;
vValue = null;
break;
case 'imgImage' :
//Note that if we set UserInterface to true and vValue to null, then
//A Dialogue will appear asking for Image location.
mCommand = 'insertimage';
uInterface = true;
vValue = null;
break;
case 'imgLink' :
mCommand = 'createlink';
uInterface = true;
vValue = null;
break;
case 'imgLine' :
mCommand = 'inserthorizontalrule';
uInterface = false;
vValue = null;
break;
case 'imgUndo' :
alert ('undo'); mCommand = 'undo';
uInterface = false;
vValue = null;
break;
case 'imgRedo' :
mCommand = 'redo';
uInterface = false;
vValue = null;
break;
case 'imgOrderList' :
mCommand = 'insertorderedlist';
uInterface = false;
vValue = null;
break;
case 'imgUnOrderList' :
mCommand = 'insertunorderedlist';
uInterface = false;
vValue = null;
break;
case 'imgOutdent' :
mCommand = 'outdent';
uInterface = false;
vValue = null;
break;
case 'imgIndent' :
mCommand = 'indent';
uInterface = false;
vValue = null;
break;
case 'lstStyle' :
mCommand = 'formatblock';
vValue = ctrl.options[ctrl.selectedIndex].value ;
uInterface = false;
break;
case 'lstFontSize' :
mCommand = 'fontsize';
vValue = ctrl.options[ctrl.selectedIndex].value ;
uInterface = false;
break;
case 'lstFont' :
mCommand = 'fontname';
vValue = ctrl.options[ctrl.selectedIndex].value ;
uInterface = false;
break;
case 'lstColor' :
mCommand = 'forecolor';
vValue = ctrl.options[ctrl.selectedIndex].value ;
uInterface = false;
break;
case 'imgDelete' :
mCommand = 'delete';
vValue = null;
uInterface = false;
break;
case 'imgPrint' :
mCommand = 'delete';
vValue = null;
uInterface = true;
break;
case 'imgSave' :
mCommand = 'saveas';
vValue = null;
uInterface = true;
break;
case 'imgCustom' :
var temp = table2.style.display;
if (temp == 'none')
{
var mTemp1 = myRTF.document.body.innerText;
table1.style.display = 'inline';
table2.style.display = 'inline';
myRTF.document.body.innerHTML = mTemp1;
}
else
{
//First Set the HTMLText in the TextBox
var mTemp = myRTF.document.body.innerHTML;
table1.style.display = 'none';
table2.style.display = 'none';
myRTF.document.body.innerText = mTemp;
}
break;
case 'imgFontColor' :
var oldcolor = GetEditBoxColor('forecolor');
mCommand = 'forecolor';
uInterface = false;
vValue = GetColorFromUser(oldcolor);
break;
case 'imgHighLight' :
var oldcolor = GetEditBoxColor('backcolor');
mCommand = 'backcolor';
uInterface = false;
vValue = GetColorFromUser(oldcolor);
break;
case 'imgSpecialChar' :
alert ('Special Characters will be provided soon.');
return;
break;
case 'imgSmile' :
var posX = event.screenX;
var posY = event.screenY + 20;
var screenW = screen.width; // screen size
var screenH = screen.height - 20; // take taskbar into account
//if (posX + 232 > screenW) { posX = posX - 232 - 40; } // if mouse too far right
//if (posY + 164 > screenH) { posY = posY - 164 - 80; } // if mouse too far down
var wPosition = 'dialogLeft:' +posX+ '; dialogTop:' +posY;
var newimage = showModalDialog('Smiles.html', '',
'dialogWidth:110px; dialogHeight: 140px; '
+ 'resizable: no; help: no; status: no; scroll: no; '
+ wPosition);
if (newimage == null) return; newimage = 'icons/smiles' + '/' + newimage;
mCommand = 'insertimage';
vValue = newimage;
uInterface = false;
break;
break ;
case 'imgAbout' :
alert ('HTML Area. Created by Sameers (theAngrycodeR)');
break;
}
myRTF.focus ();
myRTF.document.execCommand (mCommand, uInterface, vValue);
myRTF.focus ();
}
function GetColorFromUser(oldcolor)
{
var posX = event.screenX;
var posY = event.screenY + 20;
var screenW = screen.width; // screen size
var screenH = screen.height - 20; // take taskbar into account
if (posX + 232 > screenW) { posX = posX - 232 - 40; } // if mouse too far right
if (posY + 164 > screenH) { posY = posY - 164 - 80; } // if mouse too far down
var wPosition = 'dialogLeft:' +posX+ '; dialogTop:' +posY;
var newcolor = showModalDialog('ColorPicker.html', oldcolor,
'dialogWidth:238px; dialogHeight: 187px; '
+ 'resizable: no; help: no; status: no; scroll: no; '
+ wPosition);
return newcolor
}
function GetEditBoxColor(colorCommand)
{
return DecimalToRGB(myRTF.document.queryCommandValue(colorCommand));
}
function DecimalToRGB(value) {
var hex_string = '';
for (var hexpair = 0; hexpair < 3; hexpair++) {
var byte = value & 0xFF; // get low byte
value >>= 8; // drop low byte
var nybble2 = byte & 0x0F; // get low nybble (4 bits)
var nybble1 = (byte >> 4) & 0x0F; // get high nybble
hex_string += nybble1.toString(16); // convert nybble to hex
hex_string += nybble2.toString(16); // convert nybble to hex
}
return hex_string.toUpperCase();
}
</Script>
<Script Language="javascript">
function selDown(ctrl)
{
ctrl.style.backgroundColor = '#A78C5C';
}
function selUp(ctrl)
{
ctrl.style.backgroundColor = '#A78C5C';
}
</Script>
<Script Language="javascript">
function selOff(ctrl)
{
var mImage ;
switch(ctrl.id)
{
case 'imgCuston' :
mImage = 'customtag_off.gif';
break;
case 'imgAbout' :
mImage = 'about_off.gif';
break;
case 'imgBold' :
mImage = 'bold_off.gif';
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -