简体   繁体   中英

page in background while trying to open new page using code behind

I am trying to open a new page from the code. For this I used the following code on button click event

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);

The new page is opening properly but it has the issue that the new page goes in the background while the old page appears at top.

I need to show the new page opened at top of previous page. How can I do that.

Thanks in advance.

You can use focus() like this:

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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