Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open multiple links using a single anchor tag

Tags:

html

anchor

So here's a simple but interesting question, how can I open multiple links using single <a> element?

Using this only opens the first href

<a href="http://www.google.com" href="http://www.yahoo.com" target="_blank">Click Here</a> 
like image 781
Acidic Cloud Avatar asked Dec 20 '12 05:12

Acidic Cloud


People also ask

Is there a way to open multiple links at once?

Just right click on the link and hold it to drag a box around the links. When you release the right click of your mouse, all those links will open in new tabs. Open links in new tabs are the default action of the add-on, but you can change it open in new windows.

How do I open multiple urls in HTML?

You can try this in the anchor tag. Where in anchor tag use onclick method with the open method. Define both links using the open method, it will open two links with one click.

Can I use two href in anchor tag?

You can't have a link go to two places, but you can have it go to a php script that redirects to the second page when it's done doing whatever you need it to do.


1 Answers

You can certainly try this

Demo

<a href="http://www.microsoft.com" target="_blank" onclick="window.open('http://www.google.com'); window.open('http://www.yahoo.com');">Click Here</a> 
like image 183
Mr. Alien Avatar answered Sep 20 '22 12:09

Mr. Alien