我想做的共能是:输入正则表达式 网页中如果符合的话就 高亮显示。  我先能 根据输入的正则 找到相应的字符串。 但是怎么让他高亮呢? 比如:
<html>
<head>
  <title>无标题页</title>
<script>
</head>
<body>
  <form id="form1" runat="server">
  
  <a href="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm" >高亮1</a>
  
  <a href="http://paper.wenweipo.com/2012/05/16/CH12051655555504.htm" >高亮2</a>
  
  <a href="http://paper.wenweipo.com/2012/05/16/CH120516666666604.htm" >高亮3</a>  </form>
</body>
我用这个正则http://paper.wenweipo.com/2012/05/16/.+.htm是可以找到
            http://paper.wenweipo.com/2012/05/16/CH1205160004.htm
            http://paper.wenweipo.com/2012/05/16/CH12051655555504.htm
            http://paper.wenweipo.com/2012/05/16/CH120516666666604.htm
但是我怎么才能让 高亮1   高亮2   高亮3  这三个字符亮呢?

解决方案 »

  1.   

      说的简单一点就是 怎么能 用http://paper.wenweipo.com/2012/05/16/CH1205160004.htm 让  高亮1  的颜色改变。。
      

  2.   

    replace 替换一下,设置 高亮 样式
      

  3.   


    <html>
    <head>
      <title>无标题页</title>
    </head>
    <body>
      <form id="form1" runat="server">
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm" >高亮1</a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH12051655555504.htm" >高亮2</a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH120516666666604.htm" >高亮3</a>  </form>
    <script>
    function $(el){
    return typeof el == 'string' ? document.getElementById(el) : el;
    }
    function $t(name, cot){
    cot = cot || document;
    return cot.getElementsByTagName(name);
    }
    var s = 'http://paper.wenweipo.com/2012/05/16/.+.htm';
    var r = new RegExp(s);
    var objs = $t('a', $('form1'));
    for( var i = 0, len = objs.length; i < len; i++){
    if( r.test(objs[i].href) ){
    objs[i].innerHTML = '<span style="color:red;">'+objs[i].innerHTML+'</span>';
    }
    }



    </script>  
    </body>
    这个意思?
      

  4.   

     这个我知道  前提是假如我就知道http://paper.wenweipo.com/2012/05/16/CH1205160004.htm 。怎么让 亮。  怎么能找到 它的值。 
      

  5.   

     给出一种方案,抛砖引玉。<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head> <body>
      <form id="form1" runat="server">
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm" id="url1" ><span id="power1" >高亮1</span></a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH12051655555504.htm" >高亮2</a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH120516666666604.htm" >高亮3</a>  </form>  <script>
     
       var oa= document.getElementById("url1");
       
       if(oa.href=="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm"){   document.getElementById("power1").style.color="yellow";  }
      </script> </body>
    </html>
      

  6.   

    thl331860203
    (暗夜げ螃蟹)  没有id的时候怎么办 。
      

  7.   

    calmcrime
    (calmcrime)  能不 能改下 在输入 高亮1  的时候也 可以呢? 要怎么改 ? 改哪里呢?  
      

  8.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
     <head>
      <title> New Document </title>
      <meta name="Generator" content="EditPlus">
      <meta name="Author" content="">
      <meta name="Keywords" content="">
      <meta name="Description" content="">
     </head> <body>  <form id="form1" runat="server">
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm"  ><span id="power1" >高亮1</span></a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH12051655555504.htm" >高亮2</a>
       
      <a href="http://paper.wenweipo.com/2012/05/16/CH120516666666604.htm" >高亮3</a>  </form>
      <script type="text/javascript"> 
       var thisURL= document.links;
     
       if(thisURL!=null&&thisURL!=""){
        
        for(var i=0;i<thisURL.length;i++){
           
         if(thisURL[i]=="http://paper.wenweipo.com/2012/05/16/CH1205160004.htm"){
       
    document.getElementById("power1").style.color="red";
          }
        }
      }
     
     </script>
     </body>
    </html>
      

  9.   

    没有id  你可以根据dom对象找啊遍历啊 ,或者动态添加id 方法多的去了。1、文档对象每个都能找到, dom进行遍历 ,推荐用jquery
    2、高亮就是加不同颜色,说白了动态改变style 。http://www.happyalaric.com 个人技术博客