我在一个.NET 4.0 Web应用程序中使用这段javascript代码来兼容IE8:
ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report.aspx');popup.focus();", true);
这个代码会在新的浏览器选项卡中打开一个.aspx页面,但不会将焦点设置到新的选项卡上。我很想实现这一点,有人知道怎样做吗?
我在一个.NET 4.0 Web应用程序中使用这段javascript代码来兼容IE8:
ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report.aspx');popup.focus();", true);
并非所有浏览器都支持focus
,我认为即使在那些支持的浏览器中也存在一些错误。
尝试在给窗口焦点之前将其模糊。这很奇怪,但过去对某些人有效。
总的来说:
popup_handle.blur();
popup_handle.focus();
针对您的代码:
ClientScript.RegisterStartupScript(this.Page.GetType(), "popupOpener", "var popup=window.open('Report.aspx');popup.blur();popup.focus();", true);