找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 93|回复: 2

发文系统中一段代码不理解

[复制链接]
发表于 2010-1-18 09:22:09 | 显示全部楼层 |阅读模式 IP:江苏扬州
下面是发文系统的文章编辑页面中的一个模块,名字为post.js
document.writeln("<table width=100% height=100% cellpadding=2 cellspacing=0><tr><td align=left><select onChange=\"FormatText('FormatBlock',this[this.selectedIndex].value);\"><option selected>段落</option><option value=\"&lt;P&gt;\">正文</option><option value=\"&lt;H1&gt;\">标题一</option><option value=\"&lt;H2&gt;\">标题二</option><option value=\"&lt;H3&gt;\">标题三</option><option value=\"&lt;H4&gt;\">标题四</option><option value=\"&lt;H5&gt;\">标题五</option><option value=\"&lt;H6&gt;\">标题六</option><option value=\"&lt;PRE&gt;\">预设格式</option></select> <select name=\"selectFont\" onChange=\"FormatText('fontname', selectFont.options[selectFont.selectedIndex].value);\"><option selected>字体<option value=\"removeFormat\">默认字体<option value=\"宋体\">宋体<option value=\"黑体\">黑体<option value=\"隶书\">隶书<option value=\"幼圆\">幼圆<option value=\"楷体_GB2312\">楷体<option value=\"仿宋_GB2312\">仿宋<option value=\"新宋体\">新宋体<option value=\"华文彩云\">华文彩云<option value=\"华文仿宋\">华文仿宋<option value=\"华文新魏\">华文新魏<option value=\"Arial\">Arial<option value=\"Arial Black\">Arial Black<option value=\"Arial Narrow\">Arial Narrow<option value=\"Century\">Century<option value=\"Courier New\">Courier New<option value=\"Georgia\">Georgia<option value=\"Impact\">Impact<option value=\"Lucida Console\">Lucida Console<option value=\"MS Sans Serif\">MS Sans Serif<option value=\"System\">System<option value=\"Symbol\">Symbol<option value=\"Tahoma\">Tahoma<option value=\"Times New Roman\">Times New Roman&nbsp; &nbsp;<option value=\"Verdana\">Verdana<option value=\"Webdings\">Webdings<option value=\"Wingdings\">Wingdings</option></select> <select onChange=\"FormatText('fontsize',this[this.selectedIndex].value);\" name=\"D2\"><option class=\"heading\" selected>字体大小<option value=1>一号<option value=2>二号<option value=3>三号<option value=4>四号<option value=5>五号<option value=6>六号<option value=7>七号</option></select>");
document.writeln("<img src=images/ybb/fbcolor.gif alt=\"突出颜色\" align=absmiddle style=cursor:hand onClick=BackColor()>");
document.writeln("<img src=images/ybb/fgcolor.gif alt=\"字体颜色\" align=absmiddle style=cursor:hand onClick=foreColor()>");
document.writeln("<img src=images/ybb/replace.gif alt=\"替换\" align=absmiddle style=cursor:hand onClick=replace()>");
document.writeln("<img src=images/ybb/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand onClick=img()>");
document.writeln("<img alt=\"插入FLASH文件\" src=images/ybb/swf.gif align=absmiddle style=cursor:hand onclick=flash()>");
document.writeln("<img alt=\"插入Media Player文件\" src=images/ybb/mp.gif align=absmiddle style=cursor:hand onclick=MediaPlayer()>");
document.writeln("<img alt=\"插入RealPlayer文件\" src=images/ybb/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()>");

var FormatTextlist="插入超链接 createLink|去掉超链接 Unlink|<br>|粗体 bold|倾斜 italic|下划线 underline|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|两端对齐 justifyfull|编号 insertorderedlist|项目符号 InsertUnorderedList|减少缩进量 Outdent|增加缩进量 indent|普通水平线 InsertHorizontalRule|剪切 cut|复制 copy|粘贴 paste|撤消 undo|恢复 redo|全选 selectAll|取消选择 unselect|删除当前选中区 Delete"
var list= FormatTextlist.split ('|');
for(i=0;i<list.length;i++) {
if (list[i]=="<br>"){document.write("<br>");
}else{
var TextName= list[i].split (' ');
document.write(" <img align=absmiddle src=images/ybb/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')> ");
}
}
document.writeln("<img alt=\"清理代码\" src=images/ybb/CleanCode.gif align=absmiddle style=cursor:hand onclick=CleanCode()>");
document.writeln("</td></tr><tr><td height=100%><iframe ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100%></iframe></td></tr><tr></tr></table>");
if (document.all)
{var IframeID=frames["HtmlEditor"];}
else
{var IframeID=document.getElementById("HtmlEditor").contentWindow;}
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){IframeID.document.designMode="On"}
IframeID.document.open();
IframeID.document.write ('<script>i=0;function ctlent(eventobject){if(event.ctrlKey && window.event.keyCode==13 && i==0){i=1;parent.document.yuziform.content.value=document.body.innerHTML;parent.document.yuziform.submit();parent.document.yuziform.submit1.disabled=true;}}<\/script><body onkeydown=ctlent()>');
IframeID.document.close();
IframeID.document.body.contentEditable = "True";
IframeID.document.body.innerHTML=document.getElementById("content").value;
IframeID.document.body.style.fontSize="10pt";

function em(){
var arr = showModalDialog("inc/Emotion.htm", "", "dialogWidth:20em; dialogHeight:9.5em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
function CleanCode(){
var body = IframeID.document.body;
var html = IframeID.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>");
IframeID.document.body.innerHTML = html;
}

function FormatText(command,option)
{IframeID.focus();IframeID.document.execCommand(command,true,option);}
function CheckLength(){alert("最大字符为 "+50000+ " 字节\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");}
function emoticon(theSmilie){
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src=images/Emotions/"+theSmilie+".gif>");
}
function DoTitle(addTitle) {
var revisedTitle;var currentTitle = document.yuziform.topic.value;revisedTitle = addTitle+currentTitle;document.yuziform.topic.value=revisedTitle;document.yuziform.topic.focus();
}
function CheckForm(form){
form.content.value=IframeID.document.body.innerHTML;
MessageLength=IframeID.document.body.innerHTML.length;
if(MessageLength<2){alert("文章内容不能小于2个字符!");return false;}
if(MessageLength>50000){alert("文章内容不能超过50000个字符!");return false;}
document.yuziform.submit1.disabled = true;
}
function BackColor()
{
var arr = showModalDialog("inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
if (arr != null) FormatText('BackColor', arr);
else IframeID.focus();
}
function foreColor()
{
var arr = showModalDialog("inc/selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
if (arr != null) FormatText('forecolor', arr);
else IframeID.focus();
}
//////替换内容
function replace()
{
var arr = showModalDialog("inc/replace.html", "", "dialogWidth:22em;dialogHeight:10em;status:0;help:0");
if (arr != null){
var ss;
ss = arr.split("*")
a = ss[0];
b = ss[1];
i = ss[2];
con = IframeID.document.body.innerHTML;
if (i == 1)
{
con = bbsxp_rCode(con,a,b,true);
}else{
con = bbsxp_rCode(con,a,b);
}
IframeID.document.body.innerHTML = con;
}
else IframeID.focus();
}
function bbsxp_rCode(s,a,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);
}
//////替换内容结束
function img(){
url=prompt("请输入图片文件地址:","http://");
if(!url || url=="http://") return;
IframeID.focus();
sel=IframeID.document.selection.createRange();
sel.pasteHTML("<img src="+url+">");
}
function RealPlay(){
var arr = showModalDialog("inc/RealPlay.htm", "", "dialogWidth:22em; dialogHeight:10.5em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
function MediaPlayer(){
var arr = showModalDialog("inc/MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:10.5em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
function flash(){
var arr = showModalDialog("inc/flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
if (arr != null){
IframeID.focus()
sel=IframeID.document.selection.createRange();
sel.pasteHTML(arr);
}
}
我知道这就是发文系统编辑文章的地方,但是不明白什么意思,能不能帮忙加些注释,谢了
发表于 2010-2-10 06:05:06 | 显示全部楼层 IP:新西兰
路过....
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 07:27 , Processed in 0.286685 second(s), 14 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表