Skip to content

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

3 thoughts on “Open two links with one click HTML | Example code”

  1. Hello Rohit,

    I hope you are doing well.

    Thank you for posting this code. I just have one question.

    How do we prefill a data on these websites in a particular space once we click the ” click here” .

    Regards
    Arjun

Leave a Reply

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