這裏亞去....
這是打開彈出....
<html>
<head>
<script type="text/javascript">
var passwordPopup;
function popUpPassword()
{
passwordPopup = window.open("ChangePassword.aspx");
window.onbeforeunload = function()
{
alert("yay I reloaded!");
window.onbeforeunload = null;
}
}
</script>
</head>
<body>
<button onclick="popUpPassword();">Popup Password Change</button>
</body>
</html>
而且這用於重新加載主頁和關閉彈出...
public partial class ChangePassword : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SubmitPassword_Click(object sender, EventArgs e)
{
bool passwordChanged = true;
if (passwordChanged)
{
// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;
// Check to see if the client script is already registered.
if (!cs.IsClientScriptBlockRegistered(this.GetType(), "popUpPwScript"))
{
StringBuilder jscript = new StringBuilder();
jscript.Append("<script type=\"text/javascript\">");
jscript.Append("window.opener.location.reload(); window.close();");
jscript.Append("</script>");
cs.RegisterClientScriptBlock(this.GetType(), "popUpPwScript", jscript.ToString(), false);
}
}
else
{
//do something else
}
}
}
這個彈出窗口,它只是一個使用window.open()打開的新瀏覽器窗口嗎? – CyberDude 2010-09-03 10:29:14
我的回答有幫助嗎? – hyprsleepy 2010-09-15 17:53:50