以编程方式在 ie7 中打开新选项卡
我正在使用 c#、Aspnet 3.5 和 Ajax 2.0 开发 Web 应用程序。
问题 - 我在 ie7 中运行 Application_1。 我想以编程方式开始在新选项卡中从 Application_1 运行 Application_2,无论客户端设置是什么。
到目前为止,我一直在从 Application_1 的新窗口中打开 Application_2,使用“
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "window.open('theurl',' width=800, height=500'); ", true);
我想执行类似打开新选项卡”的操作。
I am developing web applications with c#, Aspnet 3.5, and Ajax 2.0.
Question - I run Application_1 in ie7. I would like to programmatically start running Application_2 from Application_1 in a new tab, no matter what the client settings are.
Until now I have been opening Application_2 in a new window from Application_1 using
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID, "window.open('theurl',' width=800, height=500'); ", true);
I would like to do something similar to open a new tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不幸的是,无法控制窗口是在新选项卡还是新窗口中打开。 这是无法在代码中覆盖的用户设置。
Unfortunately there is no way to control whether the window opens in a new tab or new window. This is a user setting that can't be overridden in code.
如果您感兴趣的话,这是微软的理由。
“关于脚本,除了目前多个窗口可用的功能之外,没有“target='_tab'”功能或任何从脚本直接访问选项卡的功能。我们正在努力平衡是否从脚本打开窗口的默认行为在新框架或选项卡中打开。"
您可以通知您的用户,按住 ctrl+shift 并单击链接将在新选项卡中打开。
Here is Microsoft's justification if you're interested.
"Regarding script, there is no "target='_tab'" feature or any direct access to tabs from script beyond what is available with multiple windows today. We are working on balancing the default behavior for whether a window opened from script opens as in a new frame or a tab."
You could inform your user that by holding ctrl+shift and clicking a link will open in a new tab.
正如保罗已经指出的,这不能通过任何脚本或代码来完成。
我认为最好让您的用户决定(通过他们各自的浏览器设置)他们想要如何打开新页面 - 在新窗口中或在同一窗口的新选项卡中。
As Paul already noted, this cannot be done via any script or code.
I think it's best to let your users decide (via their individual browser settings) how they want to open the new page - in a new window or in a new tab in the same window.