JavaScript弹出窗口:显示位置 [英] JavaScript Popup: Display Position
本文介绍了JavaScript弹出窗口:显示位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:Button ID="Button2" runat="server" Text="Show Custome-Popup" onclick="Button2_Click" />
<div align ="center" id="popup1" style =" background-color :Fuchsia; width :265px; height :183px; display :none">
popup message
</div>
//================================================ ==后面的代码=====
//==================================================Code behind=====
protected void Button2_Click(object sender, EventArgs e)
{
string javaScript = "<script language=JavaScript>\n" +
"var obj = document.getElementById('popup1');\n" +
"obj.style.display = 'block';\n" +
"</script>";
ClientScript.RegisterStartupScript(this.GetType(), "Button2_Click", javaScript);
}
//================================================ ===========
流行音乐显示完美.
但是它显示在所有其他现有控件的下方,例如textBox,label等.
//============================================================
Pop is displaying perfectly.
But it is displaying below all the other existing controls like textBox, label etc.
How can I display it in the centre of the screen over all other controls.
推荐答案
增加popup1 style的z-index ="z-index:10000;".
这会将弹出式窗口置于所有控件之上.
将您的html更改为
increase the z-index of popup1 style="z-index:10000;"
this will bring the popup above all controls.
Change your html as
<div align="center" id="popup1" style="z-index:10000; removed:absolute; background-color :Fuchsia; width :265px; height :183px; display :none;">
popup message
</div>
并将javascript更改为
and change javascript as
document.getElementById("popup1").style.position = "absolute";
document.getElementById("popup1").style.top = "100px";
document.getElementById("popup1").style.left = "100px";
document.getElementById("popup1").style.display = "block";
--Pankaj
--Pankaj
谢谢Pankaj ..
完成的代码如下.
//.============== .aspx页面中的========================
< asp:Button ID ="Button2" runat =服务器" Text ="Show Custome-Popup" onclick ="Button2_Click"/>
Thank You Pankaj..
Completed code is as follows..
//================in .aspx page=========================
<asp:Button ID="Button2" runat="server" Text="Show Custome-Popup" onclick="Button2_Click" />
<div align ="center" id="popup1" style ="z-index:10000; background-color :Fuchsia; width :265px; height :183px; display :none;">
popup message
</div>
//=============后面的代码=====================
//==============Code Behind======================
protected void Button2_Click(object sender, EventArgs e)
{
string javaScript = "<script language=JavaScript>\n" +
"var obj = document.getElementById('popup1');\n" +
"obj.style.position = 'absolute';\n" +
"obj.style.top = '100px'; \n" +
"obj.style.left = '500px'; \n" +
"obj.style.display = 'block';\n" +
"</script>";
ClientScript.RegisterStartupScript(this.GetType(), "Button2_Click", javaScript);
}
这篇关于JavaScript弹出窗口:显示位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文