How it Works:
- Replace
https://example.com
and https://anotherexample.com
with the URLs you want to open.
- Clicking the “Open Tabs” button will trigger the
openTwoTabs
function.
- Each
window.open()
call opens a new tab with the specified URL.
Notes:
- Browsers may block popups if they detect this as unsolicited behavior. Ensure this script is triggered by a user action (like a button click) to avoid being blocked.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Open Two Tabs</title>
<script>
function openTwoTabs() {
const url1 = "https://example.com"; // Replace with your first URL
const url2 = "https://anotherexample.com"; // Replace with your second URL
// Open the two URLs in new tabs
window.open(url1, "_blank");
window.open(url2, "_blank");
}
</script>
</head>
<body>
<h1>Open Two Tabs</h1>
<button onclick="openTwoTabs()">Open Tabs</button>
</body>
</html>