替换。。正则可以
没明白楼主啥意思,楼主说详细点,如果是替换控件的value,是可以做到的。。

解决方案 »

  1.   


    <html> 
    <head> 
    <title> 无标题文档 </title> 
    </head> 
    <body> 
    <table>table1 </table> 
    <p id='aa'>需替换的内容,且内容不确定</p> <br> 
    <table>table2 </table> 
    <INPUT TYPE="button" value="替换" onclick="document.getElementById('aa').innerText='hello world'">
    </body> 
    </html> 
      

  2.   

    其实不是替换,只是想删除。但是“需替换的内容,且内容不确定”,这部分内容不在任何控件里面,只是body的一部分,但他们前面的一个table,比如table1中,我可以找到定位的关键字。
    目的是,实现浏览论坛的时候,只显示指定id的发言,其他人的发言都去掉。
    不知道我说明白了没有。
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html>
    <head>
    <title> 无??文档 </title>
    </head>
    <body>
    <table>table1 </table>
    需替的内容,且内容不定 <br>
    < <table>table2 </table>
    需替的内容,且内容不定
    </body><script type="text/javascript">
    alert(document.body.innerHTML)
    document.body.innerHTML=document.body.innerHTML.replace(/需替的内容,且内容不定/gm,"123123")
    </script> </html> 
      

  4.   

    那你是不会变通吧
    .replace(/需替的内容,且内容不定/gm,"123123")
    你要换什么你面的参数传什么
    无语
      

  5.   

    已解决了,还是谢谢大家了。
    var tb=document.getElementsByTagName("table")[0];
    tb.nextSibling.nodeValue="123123";
      

  6.   


    <html> 
    <head> 
    <title> 无标题文档 </title>
    <script type="text/javascript">
    function gettxt(){
    var a = document.getElementsByTagName("body")[0];
    for(i=0;i<a.childNodes.length;i++)
    if(!a.childNodes[i].tagName)
    alert(a.childNodes[i].nodeValue);
    }
    </script> 
    </head> 
    <body onLoad="gettxt()"> 
    <table>table1 </table> 
    需替换的内容,且内容不确定 <br> 
    <table>table2 </table> 
    </body> 
    </html>没搞错吧,都结贴了,白写了,郁闷