[已解决问题] 点2次才起作用。
提问时间: 2008-06-29 14:25
悬赏分:100 浏览:184 次

描述:
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;

提问者:Robot·H - 菜鸟二级
所有回答(1)
楼主你说的“这个按钮点2次才起作用。不知道为什么?”中“这个按钮”指的是哪一个按钮,是Div中的按钮还是Table中的按钮?
2个月前   回答者:刚刚 - 老鸟四级
评论
2个月前   Robot·H :
是zindex=3 的table中的按钮。

2个月前   Robot·H :
刚刚想了想。
这样可以解决问题。嘻嘻!

function CreateWinFrame()
{
createWindow('结算中心', 340, '#ffffff', 2, 0, 0, 0);
makeCenter();
//get focus
var obj=document.getElementById("btnCancel");
obj.focus();

}

   您需要登录以后才能回答!
 

我要提问

我的问题


快到期问题

> 问题排行榜

相关链接