document.getElementById('tb').value+=document.getElementsByTagName("a")[i].href;   这是JS代码
运行结果:
http://localhost:1043/WebSite2/Default.aspxhttp://localhost:1043/WebSite2/TextLink.aspxhttp://localhost:1043/WebSite2/Default2.aspxhttp://localhost:1043/WebSite2/Default3.aspx
我需要的结果为:
http://localhost:1043/WebSite2/Default.aspx
http://localhost:1043/WebSite2/TextLink.aspx
http://localhost:1043/WebSite2/Default2.aspx
http://localhost:1043/WebSite2/Default3.aspx
高手请出手!!

解决方案 »

  1.   

    document.getElementById('tb').value+=document.getElementsByTagName("a")[i].href+"<br>";
      

  2.   

    既然是value值,想必是个文本域吧?\r回车,\n换行document.getElementById('tb').value+=document.getElementsByTagName("a")[i].href+"\n";
      

  3.   

    document.getElementById('tb').innerHTML+="<br>"+document.getElementsByTagName("a")[i].href
      

  4.   

    你的 tb 是什么东西?  如果你把前半部分 换成 一个 变量的话  然后直接 在页面输出 这个变量 肯定没问题
    如果它是个 会 过滤掉 html 标签的东西 则<br> 会无效  
    或者 你最终是用 alert 的话 也没效果  那么这时候  你应该使用 /n 来代替 <br>
      

  5.   

    document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href+"\n";
      

  6.   

    \n  
    lux 机器 \b\n
      

  7.   

    document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href + "|";
    var array = document.getElementById( 'tb ').value.sclips("|");
    array[0]
    array[1]
    array[2]
    ...
      

  8.   

    document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href + "|";
    var array = document.getElementById( 'tb ').value.split("|");
    array[0]
    array[1]
    array[2]
    ...
      

  9.   

    用 \r 好使得很
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> 
    <title>无标题文档 </title> 
    </head> 
    <body> <textarea rows="10" cols="100" id="td"></textarea>
    <a href="http://localhost:1043/WebSite2/Default.aspx"></a>
    <a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
    <a href="http://localhost:1043/WebSite2/Default.aspx"></a>
    <a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
    <a href="http://localhost:1043/WebSite2/Default.aspx"></a>
    <a href="http://localhost:1043/WebSite2/TextLink.aspx"></a>
    <script>
    var Arr = document.getElementsByTagName("a");for(var i=0;i<Arr.length;i++)
    {
    document.getElementById('td').value+=Arr[i].href+"\r";
    }
    </script>
    </body> 
    </html> 
      

  10.   

    document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href + "|"; 
    var array = document.getElementById( 'tb ').value.split("|"); 
    array[0] 
    array[1] 
    array[2] 
    ...........
      

  11.   

    for (i=0;i<=...length;i++;)
    {
    document.getElementById( 'tb ').value+=document.getElementsByTagName( "a ")[i].href;  
    document.write("<br>"); 
    }
    楼下的看看我这么写可以么?length的值可以自己指定,也就是td的数量.
    我也是初学者.谢谢~
    不对请指正!!!