想问下:我的一串字符串中包含有<a href="../../../a.html"/>,<a href="../../../b.html"/>等,我现在想把它们同意用<a href="123/c.html"/>来替换,给个方法吧!

解决方案 »

  1.   

    ctrl+f
    替换../../../a->123/c
    替换../../../b->123/c
      

  2.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    </head>
    <script type="text/javascript">
    function replace()
    {
    var test=document.getElementsByTagName("a");
    test[0].href="http://www.qq.com";
    }
    </script>
    <body>
    <input type="button" onclick="replace()" value="replace">
    <a href="http://www.163.com">test</a>
    </body>
    </html>