悬赏园豆:100
[已关闭问题]
<DIV class=Content>
<P>描述:<BR>1:一个页面有三层z-index[1,2,3]<BR>div1:有个按钮OpenDiv,当点击时,弹出div2[遮罩层zindex=2]和一个动态createElement("table")[zindex=3]<BR>2:table里有一个按钮[type=button],点击这个按钮div2和table都被remove掉</P>
<P><BR> //删除遮蔽层 EnvelopLayer<BR> var layerBeta=document.getElementById("EnvelopLayer");<BR> layerBeta.parentNode.removeChild(layerBeta);<BR> //删除table<BR> var divid=2;<BR> var tbl=document.getElementById("Window_"+divid);<BR> tbl.parentNode.removeChild(tbl);</P>
<P>3:这个页面是aspx页面<BR>问题:这个按钮点2次才起作用。不知道为什么?<BR>如果是html页面,点击一次就会起作用。<BR>可为什么aspx页面就2次呢?</P>
<P><BR>note:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" mce_href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><FONT color=#0000ff>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</FONT></A>"><BR><html xmlns="<A href="http://www.w3.org/1999/xhtml" mce_href="http://www.w3.org/1999/xhtml"><FONT color=#0000ff>http://www.w3.org/1999/xhtml</FONT></A>">都一样.<BR></P>
<P>部分js代码</P>
<P>建立遮罩层</P>
<P>function createEnvelopLayer()<BR>{<BR> var h=document.documentElement.clientHeight;<BR> var w=document.documentElement.clientWidth;<BR> 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>");<BR> div.id="EnvelopLayer";<BR> document.body.appendChild(div);<BR>}</P>
<P mce_keep="true"> </P>
<P>//create table</P>
<P>this.oTable = document.createElement("table");<BR> <BR> this.oTable.id = "Window_" + this.id;<BR> <BR> this.oTable.style.width = this.width + "px";<BR> //this.oTable.style.height = "100px";<BR> //set zIndex<BR> this.oTable.style.zIndex="1000"<BR> <BR> //this.oTable.style.width = "100%";<BR> //this.oTable.style.height = document.body.scrollHeight<BR> //this.oTable.style.border = "1px solid #C2C3BD";<BR> this.oTable.cellSpacing = 0;<BR> //this.oTable.cellPadding = 2;<BR> this.oTable.cellPadding = 0;<BR> //this.oTable.border = 0;<BR> //this.oTable.style.backgroundColor = "#FFFFFF";</P>
<P> // determine the windows position when first open<BR> this.oTable.style.position = "absolute";<BR> this.oTable.style.left = this.x + "px";<BR> this.oTable.style.top = this.y + "px";</P>
<P> // link from the table to the JSWindow object<BR> this.oTable.jsWindow = this;</P>
<P> // if the table is clicked anywhere, show the table in front of other open windows<BR> this.oTable.onmousedown = JSWindow.prototype.onBringToFront;<BR> this.oTable.className="tanchu";</P>
<P mce_keep="true"> </P>
<P mce_keep="true">this.oContentTD.innerHTML = document.all["Div" + this.id].innerHTML;</P></DIV>