[英]How to open a page in new tab when user clicks ctrl key + link button?
I have this code which opens new page in different tab. 我有这段代码可以在其他标签中打开新页面。
protected void facebook_Click(object sender, ImageClickEventArgs e)
{
myurl = "http://www.facebook.com";
string newWin = "window.open('" + myurl + "');";
ClientScript.RegisterStartupScript(this.GetType(), "pop", newWin, true);
}
But when i press ctrl key from key board and click link button then new tab is opened but in URL 但是,当我按键盘上的ctrl键并单击“链接”按钮时,会在URL中打开新选项卡
javascript:__doPostBack('LinkButton2','') displays.
javascript:__ doPostBack('LinkButton2','')显示。 and page is empty.
页面为空。
but i want to display facebook.com in new tab. 但我想在新标签中显示facebook.com。
This might help you......In Page_Load event just add code 这可能对您有帮助...在Page_Load事件中只需添加代码
facebook.Attributes.Add("onclick", "window.open('http://www.facebook.com','List','width=600,height=500,status,resizable');return false;");
or just add facebook.Attributes.Add("onclick","window.open('http://www.facebook.com');"); 或仅添加facebook.Attributes.Add(“ onclick”,“ window.open('http://www.facebook.com');”);
I guess you are using server side control , that requires postback to get the target url or script. 我猜您正在使用服务器端控件,该控件需要回发以获取目标url或脚本。
Make anchor tag or any client side control , other code seems fine. 使锚标记或任何客户端控件,其他代码似乎很好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.