0
<a href="www.abc.com/a" target="_blank">123</a>
<a href="www.abc.com/b" target="_blank">abc</a>

Both anchor links opens on the same targeted tab when a person click on them. How do you separate them to open in different tabs rather than the same tab. This is very similiar to

window.open(url, '_blank');
  • Can you elaborate more? as your question is not well explained. – Vilas Kumkar Feb 21 '17 at 10:25
  • which browser are you using ? – Afnan Ahmad Feb 21 '17 at 10:26
  • sorry I wrong type the question, it should be 'href', but that still doesn't solve the question – Jasdev Sidhu Feb 21 '17 at 10:45
  • you have `target="_blank"` , it should work , see [here](https://www.w3schools.com/tags/att_a_target.asp) – niceman Feb 21 '17 at 10:53
  • can you tell us what browser do you have and which version ? in my case I tested two links with `href` and `target="_blank"` in Chromium 56 and firefox 51 , both links were opened in different new tabs, they weren't open in the same new tab – niceman Feb 21 '17 at 11:17
  • Possible duplicate of [Blank links opens in the same window - Why, and how to fix it?](http://stackoverflow.com/questions/7952847/blank-links-opens-in-the-same-window-why-and-how-to-fix-it) – niceman Feb 21 '17 at 12:28

3 Answers3

0

You can try this

<a href="www.abc.com/a" onclick="window.open(this.href,'_blank');return false;"> Click a </a> 
<br>
<a href="www.abc.com/b" onclick="window.open(this.href,'_blank');return false;">Click b </a>
Rupali Pemare
  • 540
  • 1
  • 9
  • 24
0

Try to use this code.

$("a").click(function(e){
e.preventDefault();
var url = $(this).attr("href");
var name = $(this).text();
console.log(url, name);

window.open(url, name);


});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="http://www.example.com/a" target="_blank">123</a>
<a href="http://www.example.com/b" target="_blank">abc</a>
Manuel Cheța
  • 480
  • 2
  • 10
-1

if I am correct then you want to open www.abc.com/a in one separate(new) tab and www.abc.com/b in another separate(new) tab, on click of links respectively.

To do so - replace src with href

<a href="www.abc.com/a" target="_blank">123</a>
<a href="www.abc.com/b" target="_blank">abc</a>

For difference between src & href you may refer- Difference between SRC and HREF

Community
  • 1
  • 1