How do you open a URL in a new browser tab instead of a new window with JavaScript? | A1Lab@FahadM to JavaScriptEnglish •
edit-2
12 days ago

How do you open a URL in a new browser tab instead of a new window with JavaScript?

message-square
0

Call **window.open(url, “_blank”, “noopener,noreferrer”)** without specifying width/height window features—modern browsers automatically open “_blank”` targets in a new tab when no popup dimensions are passed.

Open URL Safely in a New Tab

function openInNewTab(url) {
  window.open(url, "_blank", "noopener,noreferrer");
}

openInNewTab("[https://a1lab.tech](https://a1lab.tech)");

## Important Browser & Security Rules

Security: Always pass "noopener,noreferrer" so the newly opened tab cannot access window.opener on your site.

Popup blockers: Trigger window.open() directly inside a user click handler so browsers do not block the new tab.'