-2

I want to know that Can I set more than one links on single word in html? I've experimented like:

  • <a href="link1" target="_self"><a href="link2 target="_blank>Open</a></a>
  • <a href="link1" target="_self" href="link2" target="_blank">Open</a>

This is only example idea what I want to do ; of-course either of above is not working.

So, How can I set more than one links to different target on single word? Is it possible with html or <a> or something else.

Pandya
  • 198
  • 2
  • 4
  • 19

2 Answers2

0

No, you can't.

If you are open for javascript you could create a function that takes urls and have the function call window.open but that is likely to get blocked by pop-up blockers.

/* this function tries to open the
   arguments supplied to it*/
function opensesame() {
  for(var i=0; i < arguments.length; i++) {
    $('#log').append($('<div></div>').text('trying to open '+ arguments[i]));
    window.open(arguments[i]);
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- you can have a local link in href -->
<a href="#" 
   onclick="opensesame('http://www.google.com','http://stackoverflow.com');">
  open sesame
</a>

<div id="log">
</div>

From the FAQ on the window.open documentation:

How can I tell when my window was blocked by a popup blocker?
With the built-in popup blockers of Mozilla/Firefox and Internet Explorer 6 SP2, you have to check the return value of window.open(): it will be null if the window wasn't allowed to open. However, for most other popup blockers, there is no reliable way.

I leave it as an exercise for the reader to extend this to take target settings as well.

rene
  • 41,474
  • 78
  • 114
  • 152
0

No, you can't.

It's possible to have two different links in different parts of the same word, but not on the same.

<a href="l1">unif</a><a href="l2">orm</a>

You need Javascript for such thing.

Rodolfo
  • 1,091
  • 3
  • 13
  • 35