<style type="text/css"> 
.aa{gn:expression(this.onselectstart=function(){return false;})} 
</style> <table> 
<tr> 
  <td   id= "td1" class="aa"> abc </td> 
</tr> 
</table> 
<table>
<tr> 
  <td onselectstart="return true"> world </td> 
</tr> 
</table> 
<script   language= "javascript"> 
function   enableSelect(bAllowed) 

    var   td   =   document.getElementById( "td1"); 
    td.onselectstart=function(){event.returnValue=bAllowed};
}
function isshow(e) { }
</script> 
现状:当双击abc,td不能被选中,全选,会被选中。
目的:全选时候,abc也可以不被选中

解决方案 »

  1.   

    <script   language= "javascript"> 
    var lastSelection=null;
    function selects(element){
    var e,r,c;
    if(element==null)
    {
    e=event.srcElement;
    }else{
    e=element;
    }
    if(e.tagName=="TD")
    {
    c=findcell(e);
    if(c!=null){
    if(lastSelection!=null){
    deselectroworcell(window.lastSelection);
    }
    selectroworcell(c);
    lastSelection=c;
    }
    }
    window.event.cancelBubble=true;
    }
    table1.onclick=selects;
    function findcell(e){
    if(e.tagName=="TD"){
    return e;
    }else if(e.tagName=="BODY"){
    return null;
    }else{
    return findcell(e.parentElement);
    }
    }
    function selectroworcell(r){
    r.runtimeStyle.backgroundColor="darkblue";
    r.runtimeStyle.color="white";
    }
    function deselectroworcell(r){
    r.runtimeStyle.backgroundColor="";
    r.runtimeStyle.color="";
    }
    </script> try!!!
      

  2.   

    感谢!
    能把全部代码贴出来么?
    我想补充一下,控制abc不被选中,而world可以被选中