hdi.innerHTML = _istr;
hd.appendChild(hdi);

}
if(this.optUrls!=null&&this.optUrls.length>0){
var optCol = this.createByName("th");
optCol.className="th";
optCol.align="center";
optCol.width="100px";
optCol.innerHTML="操作";
hd.appendChild(optCol);
}
thead.appendChild(hd);
continue;
}

if(rows[i].tagName!="row"){
continue;
}
tempi ++;
var row = this.createByName("tr");
if(tempi%2==0){
row.className="even";
}else{
row.className="odd";
}

var cels = rows[i].childNodes;
var  cSize = cels.length; var __coli = 0;
var __optIds = new Array(cSize);
//行
for(var j = 0;j<cSize;j++){
if(cels[j].tagName!="col"){
continue;
}
var __nowId = (cels[j].getAttribute("id")==null)?cels[j].getAttribute("text"):cels[j].getAttribute("id");
var cel = this.createByName("td");
if(_aligns[__coli]!=null){
cel.align=_aligns[__coli];
}
//是否为主键
if(_keys[__coli]=="true"||_keys[__coli]=="TRUE"||_keys[__coli]=="Y"){
__optIds[__coli] = __nowId;
}

if(_hrefs[__coli]!=null){

var str = "<a href=\""+
  _hrefs[__coli]+this.getAttendChar(_hrefs[__coli])+_colids[__coli]+"="+__nowId+
  "\" target=\""+_targets[__coli]+"\">"+
  cels[j].getAttribute("text")+
          "</a>";
cel.innerHTML = str;
}else{
cel.innerHTML = cels[j].getAttribute("text");
}
__coli++;
row.appendChild(cel);
}
//显示操作栏
if(this.optUrls!=null&&this.optUrls.length>0){
var optCol = this.createByName("td");
optCol.align="center";
var optNum = this.optUrls.length;
var optStr="";
for(var opti = 0;opti<optNum;opti++){
if(this.optUrls[opti]==null){
continue;
}
optStr +=" <a href="+
 this.optUrls[opti]+this.getAttendChar(this.optUrls[opti]);

for(var optidi=0;optidi<__optIds.length;optidi++){
if(__optIds[optidi]!=null){
optStr+= _colids[optidi]+"="+__optIds[optidi]+"&";

}
}
optStr = optStr.substring(0,optStr.length-1);
optStr += ">"+
 this.optTexts[opti]+
 "</a>";

}
optCol.innerHTML = optStr;
row.appendChild(optCol);
}


tbody.appendChild(row);
}
//是否是重新加载
if(this.tableDiv.firstChild!=null){
this.tableDiv.removeChild(this.tableDiv.firstChild);
}
this.tableDiv.appendChild(tab);
if(this.page=="true"||this.page=="TRUE"||this.page=="Y"){
this.div.appendChild(this.infoDiv);
this.infoDiv.innerHTML =  this.buildInfo();
} this.loading = false;
this.loadOver();

}
//得到表的操作
XTable.prototype.getOpeators = function(el){
var _opts = el.childNodes;
var optNum = _opts.length;
if(optNum>0){
this.optUrls = new Array(optNum);
this.optTexts = new Array(optNum);
var __i=0; for(var i=0;i<optNum;i++){
if(_opts[i].tagName=="operate"){
this.optUrls[__i] = _opts[i].getAttribute("url");
this.optTexts[__i] = _opts[i].getAttribute("text");
__i++;
}
}

}
}
//页面跳转
XTable.prototype.buildInfo = function(){
var str = "<div>";
str += this.nowPage + "/" + this.pageNum;
str += "&nbsp"
if(parseInt(this.nowPage)>1){
str +="<a style=\"cursor:hand;\" id=\""+this.id+"-first\" onClick=\"+XTableHandler.firstPage(this)\">"+this.getPageButton(1,true)+"</a>"
str += " ";
str +="<a style=\"cursor:hand;\" id=\""+this.id+"-pre\" onClick=\"+XTableHandler.prePage(this)\">"+this.getPageButton(2,true)+"</a>"
}else{
str +=(this.getPageButton(1,false)+" "+this.getPageButton(2,false));
}
str += " ";
if(parseInt(this.nowPage)<this.pageNum){
str +="<a style=\"cursor:hand;\" id=\""+this.id+"-next\" onClick=\"+XTableHandler.nextPage(this)\">"+this.getPageButton(3,true)+"</a>"
str += " ";
str +="<a style=\"cursor:hand;\" id=\""+this.id+"-last\" onClick=\"+XTableHandler.lastPage(this)\">"+this.getPageButton(4,true)+"</a>"
}else{
str +=this.getPageButton(3,false)+" "+this.getPageButton(4,false);
}

str+="&nbsp;<input id=\""+this.id+"_XTABLE_GOPAGE\" type=\"text\" value=\""+this.nowPage+"\" size=\"2\" class=\"text\" style=\"text-align:right\"/>";
str+="<input type=\"Button\" value=\"go\" class\"button\" id=\""+this.id+"-goPage\" onClick=\"+XTableHandler.goPage(this)\">";
     
str += "</div>";
return str;
}
//排序按钮
XTable.prototype.getOrderButton = function(x1){
var ch = "";
if(document.all){
switch(x1){
case "+":ch="5";break;
case "-":ch="6";break;
}
}else{
switch(x1){
case "+":ch=">";break;
case "-":ch="<";break;
}
}
return ch;
}
//翻页按钮
XTable.prototype.getPageButton = function(x1,useable){
var c = (useable?"class=\"pageua\"":"class=\"pageda\"");
var ch = "";
if(document.all){
switch(x1){
case 1:ch="9";break;
case 2:ch="3";break;
case 3:ch="4";break;
case 4:ch=":";break;
}
}else{
var alt = "";
var gif = "";
switch(x1){
case 1:ch="|<";break;
case 2:ch="<";break;
case 3:ch=">";break;
case 4:ch=">|";break;

}
}
return str ="<span "+c+">"+ch+"</span>";
}

解决方案 »

  1.   


    //显示加载信息
    XTable.prototype.startLoad = function(){
    this.messageDiv.innerHTML=this.loadText;
    var xy = this.getPosition();
    var x = xy[0];
    var y = xy[1];
    this.messageDiv.style.left=x;
    this.messageDiv.style.top=y;
    this.messageDiv.style.display="inline";
    }
    //隐藏加载信息
    XTable.prototype.loadOver = function(){
    this.messageDiv.style.display="none";
    }
    //得到消息层的位置。
    XTable.prototype.getPosition = function(element){
    var xy = new Array(2);
         if ( arguments.length != 1 || element == null ) 
         { 
             element = this.div;
         } 
         var offsetTop = element.offsetTop; 
         var offsetLeft = element.offsetLeft; 
         var offsetWidth = element.offsetWidth; 
         var offsetHeight = element.offsetHeight; 
         while( element = element.offsetParent ){ 
            offsetTop += element.offsetTop; 
            offsetLeft += element.offsetLeft; 
         } 
         offsetLeft += offsetWidth/2 - this.messageDiv.offsetWidth;
         offsetTop += offsetHeight/2 - this.messageDiv.offsetHeight;
         xy[0] = offsetLeft;
         xy[1] = offsetTop;
         return xy;
    }XTable.prototype.getAttendChar = function(str){
    return /\?/g.test(str)?"&":"?";
    }
    //排序
    XTable.prototype.orderByCol = function(oid){
    if(this.orderValue!=null&&this.orderValue==oid.id){
    if(this.orderType=="DESC"){
    this.orderType = "ASC";
    }else{
    this.orderType = "DESC";
    }
    }else if(this.orderValue!=oid.id){
    this.orderType = "DESC";
    }
    this.orderValue = oid.id;
    this.reLoad();
    }
    //重新加载
    XTable.prototype.reLoad = function(){
    this.startLoad();
    this.load();
    }XTable.prototype.firstPage=function(){
    this.nowPage=0;
    this.reLoad();
    }XTable.prototype.prePage=function(){
    this.nowPage--;
    this.reLoad();
    }XTable.prototype.nextPage=function(){
    this.nowPage++;
    this.reLoad();
    }
    XTable.prototype.lastPage=function(){
    this.nowPage=this.pageNum;
    this.reLoad();
    }XTable.prototype.goPage=function(a){
    if(a>0&&a<=this.pageNum&&a!=this.nowPage){
    this.nowPage=a;
    this.reLoad();
    }
    }XTable.prototype.createByName = function(n){
    return document.createElement(n);
    }//事件监听
    XTableHandler = {
    idCounter : 0,
    idPrefix  : "-xtable-",
    all       : {},
    getId     : function() { return this.idPrefix + this.idCounter++; },
    firstPage : function (oItem) { this.all[oItem.id.replace('-first','')].firstPage(); },
    prePage   : function (oItem) { this.all[oItem.id.replace('-pre','')].prePage(); },
    nextPage  : function (oItem) { this.all[oItem.id.replace('-next','')].nextPage(); },
    lastPage  : function (oItem) { this.all[oItem.id.replace('-last','')].lastPage(); },
    goPage   :function(oItem){
    //跳转到第几页
    var nid=oItem.id.replace('-goPage','');
    var goPage = document.getElementById(nid+"_XTABLE_GOPAGE");
     if(goPage!=null){
      var goone = parseInt(goPage.value);
      //检查是否越界
      if(goone>0&&goone<=this.all[nid].pageNum&&goone!=this.all[nid].nowPage){
      this.all[nid].goPage(goone);
    }else{
    //重新赋值
    goPage.value=this.all[nid].nowPage;
    }
    }
    }
    }
      

  2.   


    http.open()
    产生的效果差不多吗?静态获取文件类容,鼠标没指示,状态栏没提示?