Open two links with one click HTML | Example code

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.

Example code open two links without JavaScript

HTML example codes:

Window open method

<html>  
<body>  
	<a href="#" onclick="window.open('http://google.com');
	window.open('http://yahoo.com');">Click to open Google and Yahoo</a>

</body>  
</html>  

Using href attribute

It will open 3 links on single click

<html>  
<body>  
	<a href="http://www.microsoft.com" target="_blank" onclick="window.open('http://www.google.com'); window.open('http://www.yahoo.com');">Click Here</a>

</body>  
</html>  

Output:

Open two links with one click HTML

Do comment if you have any doubts and suggestions on this HTML link topic.

Note: The All HTML Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.