CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
不看会后悔的Windows XP之经验谈 简单快捷DIY实用家庭影院
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  Web 开发 >  ASP

大给分了,只求帮忙解决啊!!

楼主xinkong2008(张诚)2006-08-03 14:55:22 在 Web 开发 / ASP 提问

document.writeln("<table   width=100%   height=100%   cellpadding=2   cellspacing=0   border=1   bordercolor=#eeeeee   bgcolor=#eeeeee><tr><td   align=left>");  
  var   FormatTextlist="粗体   bold|倾斜   italic|下划线   underline|上标   superscript|下标   subscript|删除线   strikethrough|删除文字格式   RemoveFormat|左对齐   Justifyleft|居中   JustifyCenter|右对齐   JustifyRight|两端对齐   justifyfull|剪切   cut|复制   copy|粘贴   paste|撤消   undo|恢复   redo"  
  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=../../inc/"+TextName[1]+".gif   alt="+TextName[0]+"   style=cursor:hand   onClick=FormatText('"+TextName[1]+"')>   ");  
  }  
  }  
  document.writeln("<img   src=../../inc/img.gif   alt=\"插入图片\"   align=absmiddle   style=cursor:hand   onClick=img()>");  
  //document.writeln("<img   alt=\"插入表情\"   src=../../inc/em.gif   align=absmiddle   style=cursor:hand   onclick=em()>");  
  document.writeln("<img   alt=\"清理代码\"   src=../../inc/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.form1.nl.value=document.body.innerHTML;parent.document.form1.submit();parent.document.newfile.submit1.disabled=true;}}<\/script><body   onkeydown=ctlent()>');  
  IframeID.document.close();  
  IframeID.document.body.contentEditable   =   "True";  
  IframeID.document.body.innerHTML=document.getElementById("nl").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("最大字符为   "+5000000+   "   字节\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.newfile.topic.value;revisedTitle   =   addTitle+currentTitle;document.newfile.topic.value=revisedTitle;document.newfile.topic.focus();  
  }  
   
  function   CheckContent(form){  
  form.nl.value=IframeID.document.body.innerHTML;  
  MessageLength=IframeID.document.body.innerHTML.length;  
  if(MessageLength<10){alert("文章内容不能小于10个字符!");return   false;}  
  if(MessageLength>9000){alert("文章内容不能超过4000个汉字!");return   false;}  
  return   true;  
  }  
   
  function   Gopreview()  
  {  
  document.preview.nl.value=IframeID.document.body.innerHTML;    
  window.open('',   'preview_page',   'resizable,scrollbars,width=750,height=450');  
  document.preview.submit()  
  }  
   
  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:9em;   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:9em;   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);  
  }  
  }  
   
   
   
  帮我看下这个文本编译器啊!  
  为什么限定不了它的字数啊??  
  if(MessageLength<10){alert("文章内容不能小于10个字符!");return   false;}  
  if(MessageLength>9000){alert("文章内容不能超过4000个汉字!");return   false;}  
   
  在怎么限制它始终就只能输入3000个字就是!  
  为什么??  
  问题点数:100、回复次数:4Top

1 楼langrenkk(langrenkk)回复于 2006-08-03 15:14:51 得分 70

function   jtrim(sstr)       //去掉左右空格  
  {  
  var   astr="";  
  var   dstr="";  
  var   flag=0;  
  for   (i=0;i<sstr.length;i++)  
  {if   ((sstr.charAt(i)!='   ')||(flag!=0))    
  {dstr+=sstr.charAt(i);  
  flag=1;  
  }  
  }  
  flag=0;  
  for   (i=dstr.length-1;i>=0;i--)  
  {if   ((dstr.charAt(i)!='   ')||(flag!=0))    
  {astr+=dstr.charAt(i);  
  flag=1;  
  }  
  }  
  dstr="";  
  for   (i=astr.length-1;i>=0;i--)   dstr+=astr.charAt(i);  
  return   dstr;  
  }    
   
  function   countlen(s){       //计算实际长度  
  var   j=0;  
      for   (var   i=0;   i<s.length;   i++)  
   
      {  
   
              if   (s.charCodeAt(i)   >   255)   j   =   j   +   2;  
   
              else   j++  
      }  
      return   j;  
  }  
   
  //调用方法  
  text1=jtrim(form1.text1.value);  
  text1_len=countlen(text1);  
  if   (text1_len<10){  
          alert("文章内容不能小于10个字符!");  
          return   false;  
  }  
  if   (text1_len>8000){  
          alert("文章内容不能大于4000个汉字!");  
          return   false;  
  }Top

2 楼xinkong2008(张诚)回复于 2006-08-03 15:48:18 得分 0

这个文本编译器还有个问题,,,  
   
  就是如果从word里复制一些文字到这个编译器里的时候,写入数据库时就是空的东西。  
   
  除了word,写入数据库就有值。。  
   
  为什么啊??  
  Top

3 楼LunTanZeng(筱淼)回复于 2006-08-03 15:53:07 得分 0

没有去掉Word的格式!Top

4 楼LunTanZeng(筱淼)回复于 2006-08-03 15:53:46 得分 30

推荐网上免费的2。7版本的编辑器,很专业Top

相关问题

关键词

得分解答快速导航

  • 帖主:xinkong2008
  • langrenkk
  • LunTanZeng

相关链接

  • Web开发类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo