【发布时间】:2014-04-23 14:22:43
【问题描述】:
我正在使用下面的代码在弹出窗口中打开页面。
ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow", "window.open('URL');", True)
但我想在新标签页中打开页面。谁能帮帮我。
【问题讨论】:
-
能否请您指定您使用的浏览器?
我正在使用下面的代码在弹出窗口中打开页面。
ScriptManager.RegisterStartupScript(Page, GetType(Page), "OpenWindow", "window.open('URL');", True)
但我想在新标签页中打开页面。谁能帮帮我。
【问题讨论】:
【讨论】:
6. Some popup blockers will allow windows opened from user initiated events, but not those opened otherwise.
【讨论】:
您可以使用ClientScript.RegisterStartupScript
我在 Google Chrome 中尝试过它的工作,但在 Firefox 中没有 在aspx代码中
<asp:Button Text="" OnClick="Button1_Click" ID="Button1" runat="server" />
在 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);
}
在 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
【讨论】:
为你检查这个例子,
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);
【讨论】:
你可以试试这个..在所有浏览器中为我工作......
ScriptManager.RegisterStartupScript(this, this.GetType(), "onclick", "javascript:window.open(
'URL','_blank','height=600px,width=600px,scrollbars=1');", true);
如果您满意,请标记为答案..
【讨论】:
试试这个
Page.ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "window.open('WebForm2.aspx', '_blank');", true);
或
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);
【讨论】:
我已经搜索并尝试了许多解决方案,但最后,这对我有用。
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "newWindow", "window.open('google.com','_blank','status=1,toolbar=0,menubar=0,location=1,scrollbars=1,resizable=1,width=700,height=400');", true);
【讨论】: