📄 edit1.js
字号:
function document.onreadystatechange()
{
Composition.document.open();
Composition.document.write("<head><LINK href='css.css' type='text/css' rel='stylesheet'><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#FFFFFF\" MONOSPACE>"+window.form.content.value+"</body>");
Composition.document.close();
//window.Composition.document.body.innerHTML=window.Composition.document.body.innerHTML+window.form1.infoBody.value;
Composition.document.designMode="On";
}
function validateMode()
{
if (! bTextMode) return true;
alert("请取消“查看HTML源代码”选项再使用系统编辑功能或者提交!");
Composition.focus();
return false;
}
function handin()
{
if (!validateMode()) return;
var strHTMLbegin;
var strHTMLend;
strHTMLbegin = "[HTML]";
strHTMLend = "[/HTML]";
self.opener.frmAnnounce.body.value+=strHTMLbegin + getPureHtml(Composition.document.body.innerHTML) + strHTMLend;
self.close();
}
function format1(what,opt)
{
if (opt=="removeFormat")
{
what=opt;
opt=null;
}
if (opt==null) Composition.document.execCommand(what);
else Composition.document.execCommand(what,"",opt);
pureText = false;
Composition.focus();
}
function format(what,opt)
{
if (!validateMode()) return;
format1(what,opt);
}
function setMode(newMode)
{
bTextMode = newMode;
var cont;
if (bTextMode) {
cleanHtml();
cleanHtml();
cont=Composition.document.body.innerHTML;
Composition.document.body.innerText=cont;
} else {
cont=Composition.document.body.innerText;
Composition.document.body.innerHTML=cont;
}
Composition.focus();
}
function getEl(sTag,start)
{
while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
return start;
}
function UserDialog(what)
{
if (!validateMode()) return;
Composition.document.execCommand(what, true);
pureText = false;
Composition.focus();
}
function foreColor()
{
if (! validateMode()) return;
var arr = showModalDialog("selcolor.html", "", "dialogWidth:360px; dialogHeight:260px; status:0");
if (arr != null) format('forecolor', arr);
else Composition.focus();
}
function fortable()
{
if (! validateMode()) return;
var arr = showModalDialog("table.html", "", "dialogWidth:360px; dialogHeight:140px; status:0");
if (arr != null){
var ss;
ss=arr.split("*")
row=ss[0];
col=ss[1];
align=ss[2];
width=ss[3];
border=ss[4];
var string;
string="<table border='"+border+"' align="+align+" width="+width+" cellpadding=0 cellspacing=0>";
for(i=1;i<=row;i++){
string=string+"<tr>";
for(j=1;j<=col;j++){
string=string+"<td width='"+width/col+"'></td>";
}
string=string+"</tr>";
}
string=string+"</table>";
content=Composition.document.body.innerHTML;
content=content+string;
Composition.document.body.innerHTML=content;
}
else Composition.focus();
}
function forlink()
{
if (! validateMode()) return;
var arr = showModalDialog("link.html", "", "dialogWidth:360px; dialogHeight:140px; status:0");
// if (arr != null) format('CreateLink', arr);
if (arr != null){
var ss;
ss=arr.split("*")
href1=ss[0];
text1=ss[1];
var string;
string="<a href='"+href1+"' traget='_blank'>"+text1+"</a>";
content=Composition.document.body.innerHTML;
content=content+string;
Composition.document.body.innerHTML=content;
}
else Composition.focus();
}
function forpic()
{
if (! validateMode()) return;
var arr = showModalDialog("pic.htm","","dialogWidth:400px; dialogHeight:340px; status:0");
if (arr != null){
var ss;
ss=arr.split("*")
url=ss[0];
alt=ss[1];
width=ss[2];
height=ss[3];
align=ss[4]
var string;
if ( width == "0")
{
if ( height == "0" )
{
string="<img src='"+url+"' border='0' alt='"+alt+"' "+align+">";
}
else
{
string="<img src='"+url+"' border='0' alt='"+alt+"' height='"+height+"' "+align+">";
}
}
else
{
if ( height == "0" )
{
string="<img src='"+url+"' border='0' alt='"+alt+"' width='"+width+"' "+align+">";
}
else
{
string="<img src='"+url+"' border='0' alt='"+alt+"' width='"+width+"' height='"+height+"' "+align+">";
}
}
content=Composition.document.body.innerHTML;
content=content+string;
Composition.document.body.innerHTML=content;
// form.infoSelectpic.checked=true;
}
else Composition.focus();
//var arr = window.open("pic.asp","","top=300,left=300,width=385,height=80,menubar=0,scrollbars=0,toolbar=0,status=0,resizable=0");
}
function cleanHtml()
{
var fonts = Composition.document.body.all.tags("FONT");
var curr;
for (var i = fonts.length - 1; i >= 0; i--) {
curr = fonts[i];
if (curr.style.backgroundColor == "#ffffff") curr.outerHTML = curr.innerHTML;
}
}
function getPureHtml()
{
var str = "";
var paras = Composition.document.body.all.tags("P");
if (paras.length > 0) {
for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str;
} else {
str = Composition.document.body.innerHTML;
}
return str;
}
var bLoad=false
var pureText=true
var bodyTag="<head><style type=\"text/css\">body {font-size: 10.8pt}</style><meta http-equiv=Content-Type content=\"text/html; charset=gb2312\"></head><BODY bgcolor=\"#FFFFFF\" MONOSPACE>"
var bTextMode=false
public_description=new Editor
function Editor()
{
this.put_HtmlMode=setMode;
this.put_value=putText;
this.get_value=getText;
}
function getText()
{
if (bTextMode)
return Composition.document.body.innerText;
else
{
cleanHtml();
cleanHtml();
return Composition.document.body.innerHTML;
}
}
function putText(v)
{
if (bTextMode)
Composition.document.body.innerText = v;
else
Composition.document.body.innerHTML = v;
}
function InitDocument()
{
Composition.document.open();
Composition.document.write(bodyTag);
Composition.document.close();
bLoad=true;
}
function doSelectClick(str, el) {
var Index = el.selectedIndex;
if (Index != 0){
el.selectedIndex = 0;
if (el.id == "specialtype")
specialtype(el.options[Index].value);
else
format(str,el.options[Index].value);
}
}
var bIsIE5 = navigator.userAgent.indexOf("IE 5") > -1;
var edit;
var RangeType;
function specialtype(Mark){
var strHTML;
if (bIsIE5) selectRange();
if (RangeType == "Text"){
strHTML = "<" + Mark + ">" + edit.text + "</" + Mark + ">";
edit.pasteHTML(strHTML);
Composition.focus();
edit.select();
}
}
function selectRange(){
edit = Composition.document.selection.createRange();
RangeType = Composition.document.selection.type;
}
function rCode(s,a,b){
var r = new RegExp(a,"gi");
return s.replace(r,b);
}
function help()
{
var helpmess;
helpmess="-----------填写帮助-----------\r\n\r\n"+
"1.请不要发表有危险性的脚本。 \r\n\r\n"+
"2.如果要书写源代码,请选中\r\n\r\n"+
" 查看HTML源代码书写.\r\n\r\n"+
"3.需要你自己运行,才能看效果.\r\n\r\n"+
"4.如果书写js,尽量不要在这儿书写.\r\n\r\n";
alert(helpmess);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -