我需要在浏览器的新标签页中打开当前网页的网址。我们如何从控制器操作中打开一个新选项卡。
public ActionResult AddDocumentControls(int DocInfo)
{
url="www.test.com";
if(DocInfo==1)
{
open the url in a new tab
}
}
我试过
Page.ClientScript.RegisterStartupScript(
this.GetType(), "OpenWindow", "window.open('url','_newtab');", true);
但是Page.ClientScript没有到达。
任何人都可以给我一些帮助。谢谢。
答案 0 :(得分:1)
试试这个,
@Html.ActionLink("linkText", "Action", new {controller="Controller"}, new {target="_blank"})
<a href="@Url.Action("Action", "Controller")" target="_blank">Link Text</a>
Javascript方法,
window.open("Link URL")