vb.net 如何在新标签页中打开弹出页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22470305/
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 17:08:30  来源:igfitidea点击:

How to open popup Page in New tab

asp.netvb.net

提问by Sumanta

I am using below code for open page in popup window.

我在弹出窗口中使用以下代码打开页面。

ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow",     "window.open('URL');", True)

But i want to page open in New Tab. Can any one help me in that.

但我想在新标签页中打开页面。任何人都可以帮助我。

采纳答案by angus

You will need to make the JavaScript call a user initiated event.

您需要使 JavaScript 调用成为用户发起的事件。

Please see thisquestion and answer for further details (specifically, see point 3 in the answer).

有关更多详细信息,请参阅问题和答案(具体请参阅答案中的第 3 点)。

Working example.

工作示例

<input type="button" value="Click Me" onclick="openWindow()" />

<input type="button" value="Click Me" onclick="openWindow()" />

function openWindow() { window.open('http://www.google.com/', '_blank'); }

function openWindow() { window.open('http://www.google.com/', '_blank'); }

回答by Jameem

You can try this..working for me in all browsers...

你可以试试这个......在所有浏览器中对我来说有效......

ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open(

'URL','_blank','height=600px,width=600px,scrollbars=1');", true);

Please Mark as answer if it satisfies you..

如果您满意,请标记为答案。

回答by Sambasiva

check this example for you,

为你检查这个例子,

 ScriptManager.RegisterClientScriptBlock(btnsave, this.GetType(), "Open",
"window.open('GenerateDCNoPrint.aspx?indentno=" + ddlindentno.SelectedItem.Text + 
"&orderno=" + ddlindentno.SelectedValue + "&lorryno=" + txtlorryno.Text.Trim() + 
"&depaturetime=" + txtdeparture.Text.Trim() + "&date=" + txtdate.Text + "', 
'_blank','dependent,resizable=yes,scrollbars=yes,top=0,height=600');", true);

回答by Zeud

try this

尝试这个

Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('WebForm2.aspx', '_blank');", true);

or

或者

 string url = "WebForm2.aspx";
 string s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');";
 ClientScript.RegisterStartupScript(this.GetType(), "script", s, true);

回答by Ganesh_Devlekar

You can use ClientScript.RegisterStartupScript

您可以使用 ClientScript.RegisterStartupScript

I tried In Google Chrome its working but Not In Firefox In aspx Code

我在 Google Chrome 中尝试过它的工作,但在 aspx 代码中的 Firefox 中没有

 <asp:Button Text="" OnClick="Button1_Click" ID="Button1" runat="server" />

In C#

在 C# 中

protected void Button1_Click(object sender, EventArgs e)
{
    string queryString = "test.aspx" ;
      string newWin = "window.open('" + queryString + "','_blank');";
    ClientScript.RegisterStartupScript(this.GetType(), "pop", newWin, true);
}

In VB

在VB中

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

    Dim queryString As String = "test.aspx" 
    Dim newWin As String = "window.open('" + queryString + "','_blank');";
    ClientScript.RegisterStartupScript(Me.GetType(), "pop", newWin, True)

End Sub

回答by voddy

Try replacing this with your script

尝试用您的脚本替换它

window.open('URL', '_blank')

and I think it's browser setting that decide whether to open new window or tab. Have a look in to that as well.

我认为是浏览器设置决定是否打开新窗口或标签。也看看。

found this; If nothing works try this link

发现了这个;如果没有任何效果,请尝试此 链接