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'>'" + 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


<a href="javascript:" onclick="'');" target="_blank">Sample Code</a>

Have you try this code: Originally shared here

function OpenInNewTab(url )
  var, '_blank');

In most cases, this should happen directly in the onclick handler for the link to prevent pop-up blockers and the default "new window" behavior. You could do it this way or by adding an event listener to your DOM object.

<div onclick="OpenInNewTab('');">Something To Click On</div>

Please also try this:

Add your form name attribute like:

<form name="form">

and then try it like that:

<a href="" onclick=" form.url.value, 'windowName' ); return false" target="_blank">Submit</a>

and check this link


You can use:,'_target')

_target opens the page in next tab.


Html Code :

<button onclick="OpenInNewTab();" type="submit">

Javascript Code :

function OpenInNewTab(url) {
    var win =, '_blank');

Change Your Browser Setting.

In FireFox ,

Go To Options -> Tab setting and Check "Open New Windows in a New Tab instead" setting.

This Solution Worked For me .


I think answer to this question will help , Open a URL in a new tab using JavaScript

try like this,

$('#myButton').click(function () {
    var redirectWindow ='url', '_blank');


Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.