csharp 在新选项卡中打开窗口
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 在新选项卡中打开窗口相关的知识,希望对你有一定的参考价值。
var win = window.open("", '_blank');
win.focus();
/*********************/
HttpContext context = HttpContext.Current; if ((String.IsNullOrEmpty(target) || target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures)) { context.Response.Redirect(url); }
else
{
Page page = (Page)context.Handler;
if (page == null)
{
throw new InvalidOperationException("Cannot redirect to new window outside Page context.");
}
if (SessionManager.IsRedirectPrint)
{
context.Response.Redirect(url );
SessionManager.IsRedirectPrint = false;
return;
}
url = page.ResolveClientUrl(url);
string script;
// setTimeout ( function(){ window.open('../License/AddBuildingLicenseOld.aspx'); } , 1000);
if (!String.IsNullOrEmpty(windowFeatures))
{
script = @" window.open('{0}', '{1}', '{2}' ); ";
}
else
{
script = @" window.open('{0}', '{1}' ); ";
}
script = "setTimeout ( function(){ " + String.Format(script, url, target, windowFeatures) + " } , 1000);";
ScriptManager.RegisterStartupScript(page, typeof(Page), "Redirect", script, true);
}
public static void OpenPopup(String url)
{
HttpContext context = HttpContext.Current;
string script = "window.open('" + url + "', 'popup_window', 'menubar=no,toolbar=no,fullscreen=no,resizable=yes,scrollbars=yes,directories=no,status=no,help=no');";
Page page = (Page)context.Handler;
if (page == null)
{
throw new InvalidOperationException("Cannot redirect to new window outside Page context.");
}
url = page.ResolveClientUrl(url);
ScriptManager.RegisterStartupScript(page, typeof(Page), "OpenPopup", script, true);
}
以上是关于csharp 在新选项卡中打开窗口的主要内容,如果未能解决你的问题,请参考以下文章
如何根据登录成功在新窗口/选项卡或同一窗口/选项卡中打开页面?
使用 Thymeleaf 创建在新窗口/选项卡中打开的链接
使用“nofollow/赞助”时,window.open 在新窗口而不是新选项卡中打开
Flash应该在新选项卡中打开窗口,但它会在Mac上打开一个新的弹出窗口
在本机 iOS 中未加载在新窗口或选项卡中打开的链接
js跳转页面在新选项卡中打开