点你2次才有反应

描述:
1:一个页面有三层z-index[1,2,3]
div1:有个按钮OpenDiv,当点击时,弹出div2[遮罩层zindex=2]和一个动态createElement("table")[zindex=3]
2:table里有一个按钮[type=button],点击这个按钮div2和table都被remove掉


    //删除遮蔽层 EnvelopLayer
        var layerBeta=document.getElementById("EnvelopLayer");
        layerBeta.parentNode.removeChild(layerBeta);
    //删除table
    var divid=2;
        var tbl=document.getElementById("Window_"+divid);
        tbl.parentNode.removeChild(tbl);

3:这个页面是aspx页面
问题:这个按钮点2次才起作用。不知道为什么?
如果是html页面,点击一次就会起作用。
可为什么aspx页面就2次呢?


note:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">都一样.

部分js代码

建立遮罩层

function createEnvelopLayer()
{
    var h=document.documentElement.clientHeight;
    var w=document.documentElement.clientWidth;
    var div=document.createElement("<div id='EnvelopLayer' style='position:absolute;visibility:visible;background:#000;filter:alpha(opacity=20);z-index:500;left:0;top:0;width:"+w+"px;height:"+h+"px;color:#fff'></div>");
    div.id="EnvelopLayer";
    document.body.appendChild(div);
}

 

//create table

this.oTable = document.createElement("table");
   
    this.oTable.id = "Window_" + this.id;
 
 this.oTable.style.width = this.width + "px";
 //this.oTable.style.height = "100px";
 //set zIndex
 this.oTable.style.zIndex="1000"
 
 //this.oTable.style.width = "100%";
 //this.oTable.style.height = document.body.scrollHeight
 //this.oTable.style.border = "1px solid #C2C3BD";
  this.oTable.cellSpacing = 0;
 //this.oTable.cellPadding = 2;
 this.oTable.cellPadding = 0;
 //this.oTable.border = 0;
 //this.oTable.style.backgroundColor = "#FFFFFF";

 // determine the windows position when first open
 this.oTable.style.position = "absolute";
 this.oTable.style.left = this.x + "px";
 this.oTable.style.top = this.y + "px";

 // link from the table to the JSWindow object
 this.oTable.jsWindow = this;

 // if the table is clicked anywhere, show the table in front of other open windows
 this.oTable.onmousedown = JSWindow.prototype.onBringToFront;
    this.oTable.className="tanchu";

 

this.oContentTD.innerHTML = document.all["Div" + this.id].innerHTML;

你可能感兴趣的:(点你2次才有反应)