繁体   English   中英

尝试使用背后的代码打开新页面在背景中的页面

[英]page in background while trying to open new page using code behind

我试图从代码中打开一个新页面。 为此我在按钮点击事件上使用了以下代码

string pageURL = UIConstants.Url.PrintUserBRCs + "?" + UIConstants.ReportType + "=" + UIConstants.DetailReport;

string script = string.Format("window.open('{0}', null, 'height=600, width=800, status=yes, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes, titlebar=yes')", pageURL);

Page.ClientScript.RegisterClientScriptBlock(GetType(), "LaunchTemplate", script, true);

新页面正常打开,但问题是新页面在后台显示,而旧页面显示在顶部。

我需要显示在上一页顶部打开的新页面。 我怎样才能做到这一点。

提前致谢。

您可以像这样使用focus()

string script = string.Format("var newWindow = window.open('{0}', null, 'height=600, width=800, status=yes, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes, titlebar=yes');"
                                      + " newWindow.focus();", pageURL);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM