ASP.NET打开新窗口方法一:
Response.Write("<script language=\"javascript\">window.open('aaa.aspx','新窗口,\"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes\");</script>");
这种方式代码每次是生成在页面最顶端
ASP.NET打开新窗口方法二:
string strScript = "";
strScript += "<script language=\"javascript\">\n";
strScript += "window.open('aaa.aspx','新窗口,\"toolbar=yes,location=no,directories=yes,status=yes,menubar=yes,resizable=yes,scrollbars=yes\");\n";
strScript += "location.href='index.html';";
strScript += "</script>";
bool b = ((Page)System.Web.HttpContext.Current.Handler).IsStartupScriptRegistered("PopUp");
if (!b)
{
((Page)System.Web.HttpContext.Current.Handler).RegisterStartupScript("PopUp",strScript);
}
这种方式是在页面中生成JAVASCRIPT代码
注意:如果输出JAVSSCRIPT语句后,页面又用Response.Redirect跳转到其他页,JAVASCRIPT将不会出现.
实现弹出窗口和跳转同时必须都在JAVASCRIPT语句里,
asp.net中打开新窗口的多种方法
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open(XXX.aspx'',''_blank'')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location=XXX.aspx''</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog(XXX.aspx'')</script>")——原窗口保留,以对话框形式打开新窗口;
6.Response.Write("<script>window.showModalDialog(XXX.aspx'')</script>")——对话框形式打开新窗口,原窗口被代替;
------------------------
为什么如下语句能使用,能正确执行.如下
Response.Write("<script language=javascript>window.open('repair.aspx?UN="+usernumber+"&SID="+serviceID+"')</script>");
而加上参数后就不能执行了呢?如下
Response.Write("<script language=javascript>window.open('repair.aspx?UN="+usernumber+"&SID="+serviceID+"','toolbar=no,status=no')</script>");
----------------------------------------------------------------------
Response.Write("<script language=javascript>window.open('repair.aspx?UN="+usernumber+"&SID="+serviceID+"',’’,'toolbar=no,status=no')</script>");
这样看看!
--------------------------------------------------------
把逗号换成分号toolbar=no;scrollbars=no
--------------------------------------------
asp.net中打开新窗口的多种方法(转载)
1.Response.Redirect("XXX.aspx",true)——直接转向新的页面,原窗口被代替;
2. Response.Write("<script>window.open(XXX.aspx','_blank')</script>")——原窗口保留,另外新增一个新页面;
3.Response.Write("<script>window.location=XXX.aspx'</script>")——打开新的页面,原窗口被代替;
4.Server.Transfer("XXX.aspx")——打开新的页面;
5.Response.Write("<script>window.showModelessDialog(XXX.aspx')</script>")——原窗口保留,以对话框形式打开新
-----------------------
<script language="javascript">
function popupkind(xdm)
{
url ="ThisTerm2Add.aspx?xdm="+xdm
hr=window.showModalDialog(url,'',"dialogHeight:300px;dialogWidth:300px;dialogLeft:60px;dialogTop:30px;center:1;status:1;title:0;")
}
</script>