You wanted to access the root document of server www.google.com, which is done using the url https://www.google.com/. You provided a relative url for document www.google.com instead.

Keep in mind that window.open accepts both relative and absolute urls, so it can't assume you left out https:// as it does when you use www.google.com in the address bar.


Maybe an example will help. Say the current page is http://www.example.com/dir/foo.html.

  • window.open("popup.html", "_blank") opens
    http://www.example.com/dir/popup.html.
  • window.open("www.google.com", "_blank") therefore opens
    http://www.example.com/dir/www.google.com.

The browser has no way of knowing you actually wanted https://www.google.com/ when you said you wanted http://www.example.com/dir/www.google.com since the latter could be valid.

Answer from ikegami on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN - Mozilla
The Window interface's open() method takes a URL as a parameter, and loads the resource it identifies into a new or existing tab or window.
Discussions

Open URL in new window with JavaScript - Stack Overflow
I'm making a "share button" to share the current page. I would like to take the current page URL and open it in a new window. I have the current URL part working, but can't seem to get the next part More on stackoverflow.com
🌐 stackoverflow.com
window.open external link opening in new tab
So I have a confirmation dialog box that opens when button is clicked, but window.open in javascript opens it in new tab. I tried lot of things like _self, _top but it doesn't work. Is there any wa... More on stackoverflow.com
🌐 stackoverflow.com
July 18, 2017
Launch Chrome Browser without Address Bar, Tabs or Bookmarks on Windows PC (not Full-screen)
I had this wish for a long time, since I wanted to view some pages without all the additional Chrome stuff (Bookmarks, tabs, address bar), but no… More on reddit.com
🌐 r/chrome
1
1
August 18, 2020
[deleted by user]
You could try adding a standard but style it with a CSS of display: hidden. Then your JavaScript is just going to do the click on that link x effectively simulating a user doing it. It might work, I’ve not had to try it myself. More on reddit.com
🌐 r/Blazor
21
0
April 6, 2023
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-open-url-in-a-new-window-using-javascript
How to open URL in a new window using JavaScript? - GeeksforGeeks
August 21, 2025 - By specifying target="_blank", the link will open in a new tab. This approach is straightforward and commonly used for external links, enhancing user experience by keeping the current page intact.
Find elsewhere
🌐
Apache Cordova
cordova.apache.org › docs › en › 3.1.0 › cordova › inappbrowser › window.open.html
window.open - Apache Cordova
<!DOCTYPE html> <html> <head> <title>window.open Example</title> <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for device API libraries to load // document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { // external url var ref = window.open(encodeURI('http://apache.org'), '_blank', 'location=yes'); // relative document ref = window.open('next.html', '_self'); } </script> </head> <body> </body> </html>
🌐
W3Docs
w3docs.com › html
How to Open Hyperlink in a New Window
How to open hyperlink in a new tab using the target="_blank" attribute. Learn also how to do that by using JavaScript window.open function. See examples.
🌐
HashBangCode
hashbangcode.com › article › using-jquery-open-external-links-new-window
Using JQuery To Open External Links In A New Window | #! code
$("a[href^='http']:not([href*='example.com'])").click(function(){ window.open(this.href,'','width=200,height=100'); return false; }).attr("title", "Opens in a new window"); ... $("a[href*='http://']:not([href*='"+location.hostname.replace("www.","")+"'])").each(function() { //do some 'stuff' ...
🌐
SitePoint
sitepoint.com › blog › javascript › jquery open all hyperlinks in new window
jQuery Open All Hyperlinks in New Window — SitePoint
February 13, 2024 - The window.open() method can be used for this purpose. The second parameter of this method specifies the target where the URL should be opened. If you set this parameter to “_blank”, the URL will be opened in a new tab. Here’s an example: $("a").click(function(event) { event.preventDefault(); ...
🌐
Robwise
robwise.github.io › blog › javascript-external-links-open-new-window
Use JavaScript to Make External Links Open in a New Window
August 11, 2015 - // Supports IE8+. Courtesy of http://youmightnotneedjquery.com/ function ready(fn) { if (document.readyState != 'loading') { fn(); } else if (document.addEventListener) { document.addEventListener('DOMContentLoaded', fn); } else { document.attachEvent('onreadystatechange', function() { if (document.readyState != 'loading') fn(); }); } } ready(function() { var website = window.location.hostname; var internalLinkRegex = new RegExp('^((((http:\\/\\/|https:\\/\\/)(www\\.)?)?' + website + ')|(localhost:\\d{4})|(\\/.*))(\\/.*)?$', ''); var anchorEls = document.querySelectorAll('a'); var anchorElsLength = anchorEls.length; for (var i = 0; i < anchorElsLength; i++) { var anchorEl = anchorEls[i]; var href = anchorEl.getAttribute('href'); if (!internalLinkRegex.test(href)) { anchorEl.setAttribute('target', '_blank'); } } });
🌐
Zipy
zipy.ai › blog › how-to-open-a-url-in-a-new-tab-and-not-a-new-window
how to open a url in a new tab (and not a new window)
April 12, 2024 - It's a user-friendly way to redirect ... external sites, or documentation without navigating away from the original page. This technique is crucial in keeping users engaged while providing them with more value. Debug and fix code errors with Zipy Error Monitoring. ... JavaScript stands at the core of dynamic web development, offering a plethora of methods to manipulate the DOM and control the browser's behavior. One such capability is opening URLs in new tabs using the window.open() ...
🌐
Little-fire
little-fire.com › home › make all external links open in a new window
Make all External Links Open in a New Window | Little Fire Digital Ltd
February 6, 2025 - External links are typically identified ... a link to Google. To make a link open in a new window, you need to add the target="_blank" attribute to the anchor tag....
Address   Unit R10, Sheaf Bank Business Park, S2 3EN, Sheffield
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › how-to-open-url-in-new-tab-using-javascript
How to Open URL in New Tab using JavaScript? - GeeksforGeeks
window.open("https://www.geeksforgeeks.org////", "_blank"); opens the GeeksforGeeks website in a new tab. Here are the applications of opening URLs in new tabs: External Links: When linking to external websites, it’s best to open them in a new tab to keep users on your site.
Published   August 21, 2025
🌐
CoreUI
coreui.io › blog › how-to-open-link-in-a-new-tab-in-html
How to Open Link in a New Tab in HTML? · CoreUI
February 26, 2025 - href attribute specifies: Tells your HTML parser exactly which linked URL to fetch. rel attribute: Helps define the relationship between the original page and the newly opened tab, often used for security measures. When you want to open the linked document in a new tab, you typically use target="_blank". This target value instructs the browser to create a new page, also known as a new tab or window.
🌐
CSS-Tricks
css-tricks.com › snippets › jquery › open-external-links-in-new-window
Open External Links In New Window | CSS-Tricks
March 19, 2013 - I don’t want the links to open on new window or in same window, I want them to open in same div “showresult”. ... Thanks for this tip, Chris. The second jQuery snippet, with a mod to the specific URL needed, made it easy to open redirections of specific URLs in a new tab – on a WordPress ...
🌐
w3tutorials
w3tutorials.net › blog › open-url-in-same-window-and-in-same-tab
How to Open a URL in the Same Window and Tab Using JavaScript (Fixing window.open New Tab Issue) — w3tutorials.net
For most cases where you want to navigate in the same tab, window.open() is overkill. Instead, use the window.location object, which provides direct control over the current tab’s URL.
🌐
GeeksforGeeks
geeksforgeeks.org › html › how-to-open-a-hyperlink-in-another-window-or-tab-in-html
How to Open a Hyperlink in Another Window or Tab in HTML? - GeeksforGeeks
November 23, 2024 - In HTML, this can be easily achieved using the 'target' attribute of the anchor ('<a>') tag. By setting 'target="_blank"', you instruct the browser to open the linked document in a new tab or window.
🌐
DEV Community
dev.to › hardiquedasore › secure-way-to-open-an-external-link-in-a-new-tab-or-window-41m9
Secure way to open an external link in a new tab or window - DEV Community
January 11, 2023 - In order to open a link from your website, we need to use the anchor tag <a> in HTML. Inside... Tagged with html, webdev.