Skip to content

How to open all links on a page | Example code

  • by

You can use Window open method into a anchor tag to open all links on a page.

How to open all links on a page Example

HTML example opening a 2 tabs, but you can add more tabs.

<html>
<body>

	<a
     onclick=" window.open('https://eyehunts.com','','width=700,height=700'); 
               window.open('https://google.com/','','width=700,height=500')">Click Here</a>
</body>
</html>

Output: Note (Unblock the pop up windows for your browser and the code could work)

open all links on a page

Basic implementation in JavaScript

Open all link on a single link click.

<html>
<body>

	<a href="" id="multi-link-opener" onclick="openMultipleLinks(myLinks)">Click To Open Links</a>

	<script>
		var myLinks = [
		"https://google.com",
		"https://eyehunts.com",
		"https://yahoo.com"
		]

		function openMultipleLinks(links) {
			for (var i = 0; i < links.length; i ++) {
				window.open(links[i]);
			} 
		}	
	</script>
</body>
</html>

Do comment if you have any doubts and suggestions on this 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 *