从后面的 vb.net 代码在新选项卡中打开新链接

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29793939/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:03:07  来源:igfitidea点击:

Open new link in new tab from vb.net code behind

javascriptasp.netvb.net

提问by Rajan Goswami

I am trying to open a link in a new tab from my vb.net code behind code. This is my code.

我正在尝试从我的 vb.net 代码背后的代码中打开一个新选项卡中的链接。这是我的代码。

Dim s As String = "window.open('" & url & "', '_blank', 'left=100,top=100,resizable=yes');"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alertscript", s, True)

but this is opening a new popup window. I want to open the url in a new tab of the same window.

但这是打开一个新的弹出窗口。我想在同一窗口的新选项卡中打开 url。

回答by Kyojimaru

just change your script to

只需将您的脚本更改为

Dim s As String = "window.open('" & url & "', '_blank');"
Page.ClientScript.RegisterStartupScript(Me.GetType(), "alertscript", s, True)

You just need to use the '_blank'without 'left=100,top=100,resizable=yes'if you want it to open in new tab.

如果您希望它在新选项卡中打开,您只需要使用'_blank'without 'left=100,top=100,resizable=yes'

The 'left=100,top=100,resizable=yes'will create a new window with position 100pxfrom topand left

'left=100,top=100,resizable=yes'会创建一个新的窗口位置,100pxtopleft