再UP,可是自己UP没分…… :_)
高手请帮帮忙。

解决方案 »

  1.   

    The PRE element tells visual user agents that the enclosed text is
    "preformatted". When handling preformatted text, visual user agents:   * May leave white space intact.
       * May render text with a fixed-pitch font.
       * May disable automatic word wrap.
       * Must not disable bidirectional processing.
      

  2.   

    最后一个双向操作是什么意思?请指点?
    最重要的,第三条:禁止自动换行。这个是可以理解的。
    但是,我加入
以后,是可以换行的。你试试?
    <pre>abc&#13;def</pre>
    但是,如果innerHTML它,就没有效果。
    如果innerText它,就把它原封不动显示出来了。不能理解为什么innerHTML的时候会没有效果……
      

  3.   

    最后一句pid.innerHTML=strResult;改为
    pid.outerHTML=pid.outerHTML.replace(pid.innerHTML,strResult)
      

  4.   

    <pre id=pid>
    abc abc abc abc abc abc abc abc abc
    </pre>
    <script>
    var strVar=pid.innerText;
    var a=10;  //定义每行字数
    var strResult="";
    for(i=0;i<=strVar.length-1;i=i+a)
    {
    var strTemp=strVar.substr(i,a)+"&#13;";
    strResult+=strTemp;
    }
    pid.outerHTML=pid.outerHTML.replace(pid.innerHTML,strResult)
    </script>
    这样?实验成功!厉害!————是怎么想到这样做的?