Open Multiple Tabs

There are times when you need to open many web pages. You might need just a few or lists but it can be helpful to have a tool that will open multiple url’s in their own tab. To make your own tab opener you will need a textarea, a button, and some javascript.

Click here to use the tool.

<!DOCTYPE html>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, shrink-to-fit=no, initial-scale=1">
    <title>Open Multiple Tabs</title>

</head>

<body>


<!-- textbox and button -->
<div>

	<p>Paste in a list of URL's. Presumes http://</p>

	<textarea name="urls_textBox" id="urls_textBox" rows="12"></textarea>

	<button type="button" class="btn btn-default center-block" onclick="openMultipleTabs()">Open</button>

	<p class="note">Note: Your browser might block the popup and ask you if you are sure you want to do this.</p>

</div>


<!-- script: open multiple tabs -->
<script>

	// fn: open many windows
	function openMultipleTabs() 
	{
		var textBox = document.getElementById("urls_textBox");
		var urlList = textBox.value.split('\n');
		for(var i = 0; i < urlList.length; i++)
		{
			openInNewWindow(urlList[i]);
		}
	}

	// fn: open a url in a new window
	function openInNewWindow(url)
	{
		window.open("http://" + url, "_blank");
	}

</script>


</body>
</html>

The function ‘openMultipleTabs()’ gets the contents of the textarea. It separates the contents by line. It runs the function ‘openInNewWindow()’ on each line of contents. This function uses ‘window.open()’ to open a url in a new tab. You will probably find that browsers block this kind behavior by default. The user can give permission to the page to run the script.

Leave a Reply

Your email address will not be published.

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