yash yash - 1 year ago 108
ASP.NET (C#) Question

How to open a link in new tab using javascript

I am working on a website, in which I have to open a url from backend. I am using c# now. My problem is that I want to open link in new tab instead of new window.

My code is here:-

string url = ppHref.ToString();

string newScript = "<script language='javascript'>window.open('" + ppHref.ToString() + "', '_blank');</script>";

ClientScript.RegisterStartupScript(this.GetType(),"OpenUrl", newScript);

Can Anybody tell me how to open this url in new tab. I don't like pop ups so I don't wanna use
. Please help me.

Thanks in Advance

Answer Source
<a href="javascript:" onclick="window.open('https://www.google.co.in');" target="_blank">Sample Code</a>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download