Open Multiple URLs with one click JavaScript | Example code

  • by

The open() method to opens a new browser window, or multiple new tab in JavaScript.

Example Open Multiple URLs with one click JavaScript

HTML example Code: open multiple windows on single click.

Use onclick method to call‘url’). We created a function for it. Using a for loop for multiple websites open.


	<a href="#" onclick="yourlink()">Click Here</a>


		function yourlink() {

			var locs = ['','',''] 

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


Output: is sometimes blocked by popup blockers and/or ad-filters.

Open Multiple URLs with one click JavaScript

Open 2 Multiple URLs on one-click button JavaScript Output

Open 2 Multiple URLs on one click button JavaScript

Another way without using JavaScript

You can just use a simple HTML anchor tag and onclick attribute to open 2 URLs on a single click.


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

Do comment if you have any doubts and suggestions on these JS URL examples.

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.