Skip to content

How to add two links to one button | Example code

  • by

If you are want to open a 2 link with a single click, then use JavaScript. You can also use the anchor tag and onclick attribute to open multiple links.

Add two links to one button in HTML


	<button onclick="yourlink()">Click Here</button>


		function yourlink() {

			var locs = ['', ''] 

			for (let i = 0; i < locs.length; i++) {[i])}



add two links to one button

Without using script

HTML anchor tag onclick add URLs to open 2 it on single click.


	<a href="#" onclick="'');'');">Click to open Google and Yahoo</a>

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

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

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *

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