Home >Web Front-end >JS Tutorial >Writing htc data table_javascript skills

Writing htc data table_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:20:341252browse

Author: xmg (小马哥)

Copy code The code is as follows:






<script> <br>if(document.all){ <br>    Event.prototype.__defineGetter__("srcElement",function(){var node=this.target;while(node.nodeType!=1){node=node.parentNode}return node}) <br>    Event.prototype.__defineGetter__("x",function(){return this.clientX 2}) <br>    Event.prototype.__defineGetter__("y",function(){return this.clientY 2}) <br>} <br>function $(obj){return document.getElementById(obj)} <br></script>


  
    
    
    
    
    
    
    
    
    
    
  
  
    
    
    
    
    
    
    
    
    
    
  
  
    
    
    
    
    
    
    
    
    
    
  
  
    
    
    
    
    
    
    
    
    
    
  
  
    
    
    
    
    
    
    
    
    
    
  
  
    
    
    
    
    
    
    
    
    
    
  
字段一 字段二 字段三 字段四 字段五 字段六 字段七 字段八 字段九



<script> <br>var obj=$("datagrid"),td <br>var body=document.body <br>var DragObj=null <br>var objxy=getxy(obj) <br>var Dragborder=0 <br>obj.style.cssText="background:#FFF;border-collapse:collapse" <br>for(var i=0;i<obj.rows.length;i ){ <BR>    for(var j=0;j<obj.rows[i].cells.length;j ){ <BR>        td=obj.rows[i].cells[j] <BR>        if(i==0){ <BR>            td.className="GridBorder" <BR>            td.style.cssText="font-weight:bold" <BR>        }else if(j==0){ <BR>            td.className="GridBorder" <BR>            td.style.cssText="width:15px" <BR>        }else{ <BR>            td.innerHTML="<input type=text value='" td.innerHTML.replace(/ /gi,'') "' style='width:100%;border:0px'>" <br>        } <br>    } <br>} <br>var focus_img=document.createElement("IMG") <br>focus_img.src="http://bbs.51js.com/attachment.php?aid=7290&noupdate=yes" <br>if(typeof(Dline)!="object"){ <br>    var Dragline=document.createElement("DIV") <br>    Dragline.id="Dline" <br>    Dragline.style.cssText="width:1px;border-left:1px solid #CCC;display:none;position:absolute" <br>    body.appendChild(Dragline) <br>} <br>obj.onclick=function(){ <br>    var e=event,tr <br>    var ee=e.srcElement <br>    if(ee.tagName=="INPUT"){ <br>        tr=ee.parentNode.parentNode <br>        obj.rows[tr.rowIndex].cells[0].appendChild(focus_img) <br>    } <br>} <br>obj.onmousemove=function(){ <br>    var e=event,tr <br>    var ee=e.srcElement <br>    if(ee.tagName=="TD"&&ee.parentNode.rowIndex==0&&ee.cellIndex>0){ <br>        var a=getxy(ee) <br>        if(event.x<(a[1] 5)||event.x>(a[1] a[2]-5)){ <br>            body.style.cursor="col-resize" <br>            objxy=getxy(obj) <br>        }else{ <br>            body.style.cursor="default" <br>        } <br>    } <br>} <br>obj.onmousedown=function(){ <br>    var e=event <br>    var ee=e.srcElement <br>    var a=getxy(ee) <br>    if(body.style.cursor=="col-resize"){ <br>        if(event.x<(a[1] 5)) <BR>            Dragborder=1 <BR>        else if(event.x>(a[1] a[2]-5)) <br>            Dragborder=2 <br>        else <br>            Dragborder=0 <br>        DragObj=ee <br>        $("Dline").style.left=e.x <br>        $("Dline").style.top=objxy[0] <br>        $("Dline").style.height=objxy[3] <br>        $("Dline").style.display="" <br>    } <br>} <br>body.onmousemove=function(){ <br>    if(DragObj!=null){ <br>        $("Dline").style.left=event.x <br>        body.style.cursor="col-resize" <br>    } <br>}<br>body.onmouseup=function(){ <br>    if(DragObj!=null){ <br>        $("Dline").style.display="none" <br>        body.style.cursor="default" <br>        if(Dragborder==2){ <br>            var a=getxy(DragObj) <br>            var w=event.x-a[1] <br>            w=w<=0?0:w <br>            DragObj.style.width=w <br>        } <br>        if(Dragborder==1){ <br>            var pnode=DragObj.previousSibling <br>            var a=getxy(pnode) <br>            var w=event.x-a[1] <br>            w=w<=0?0:w <br>            pnode.style.width=w <br>        } <br>        DragObj=null <br>    } <br>} <br>function getxy(e){ <br>    var a=new Array() <br>    var t=e.offsetTop; <br>    var l=e.offsetLeft; <br>    var w=e.offsetWidth; <br>    var h=e.offsetHeight; <br>    while(e=e.offsetParent){ <br>        t =e.offsetTop; <br>        l =e.offsetLeft; <br>    } <br>    a[0]=t;a[1]=l;a[2]=w;a[3]=h <br>  return a; <br>} <br></script>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn