<textarea id="i1" style="width:100%;height:200px"></textarea>
<script>
var a=document.getElementById('i1');
var s='never online\nhttp://www.never-online.net\nnever-online\'s blog:\nhttp://blog.never-online.net';
var ar=s.split('\n');
for (var i=0; i<ar.length; i++) {
var d=document.createElement("DIV");
d.style.color=i%2==0?'red':'blue';
d.innerHTML=ar[i];
a.appendChild(d);
}
</script>

解决方案 »

  1.   

    or you can use a select tag to be as the textarea
      

  2.   

    一下代码存为:笨狼取色器.hta   
      good   luck!   
          
      <html>   
      <head>   
      <meta   http-equiv="Content-Type"   content="text/html;   charset=gb2312">   
      <title>笨狼颜色选择器</title>   
      <style>   
      body,body.*   
      {   
      font-size:12;   
      }   
      span,button,input   
      {   
      margin:2;   
      width:50;   
      border:1px   solid   black;   
      height:18;   
      }   
      A   
      {   
      color:blue;   
      }   
      </style>   
      <SCRIPT   LANGUAGE="vbScript">   
        dim   aaa,counter   
      window.resizeTo   window.screen.availWidth,window.screen.availHeight     
      window.moveTo   0,0   
        
      function   randColor()   
      dim   re,i,ranNum   
      for   i=1   to   3   
      randomize   
      ranNum=hex(int(255*rnd)+1)   
      if(len(ranNum)=1)   then   ranNum="0"   &   ranNum   
      re=re   &   ranNum   
        next   
        randColor   =   "#"   &   re   
        end   function   
            
        sub   test   
      '设置最多产生1000个色块。   
      if   counter>1000   then   exit   sub   
      dim     strHTML   ,color   
      color=randColor()     
      strHTML="<span   style='background-color:"   &   color   &   ";'   onclick='vbs:getColor   me'   title='"   &   color   &     "'></span>"     
      document.body.insertAdjacentHTML   "beforeEnd",strHTML     
      counter   =counter   +1   
        end   sub   
          
      sub   getColor(obj)     
      ipt.value=obj.title   
      ipt.select   
      choice.style.backgroundColor=obj.title   
      window.clipboardData.setData     "Text",ipt.value     
      end   sub   
        
        sub   gogogo     
      aaa=window.setInterval("test","100","VBScript")     
        end   sub   
          
      sub   shutUp     
      window.clearInterval   aaa   
        end   sub   
      </SCRIPT>   
      </head>   
        
      <body>     
      <button   onclick="vbs:gogogo">选美</button>   
      <button   onclick="vbs:shutUp"   >停止</button>   
      <button   onclick="vbs:window.location.reload   "   >刷新</button>   
      <span   id="choice"></span>   
      <input   id="ipt">   
        
      <A   href="http://superdullwolf.cnzone.net">超级大笨狼制作,呜呼!~~君子好色,取之有道:)...</A>   
          
      <hr/>   
      </body>   
      </html>