'Open a chrome newtab with url chrome://newtab/
The first line works fine, but the second one doesn't work; why?
// Works
window.open('https://google.com/', '_blank');
// Doesn't work, why?
window.open('chrome://newtab/', '_blank');
Solution 1:[1]
You can just try this out:
const newtab = () =>? window.open('dummy url', '_blank');
I think that would work for you ;)
Solution 2:[2]
Due to security issues, sadly, you cannot do this in chrome. The best you can do would be to point to google.com if you want the user to have a search bar or something like that. For example, something like this would work:
<a href="https://google.com" target="_blank">Search Anything</a>
Solution 3:[3]
Unfortunately, utilizing accessible browser APIs, you won't be able to perform what you desire. window.open has the following syntax: window.open(URL, name, specs, replace). The first two specify how this new "window" will be opened. The address of the window's destination. These can be left blank, but it will open a window titled about:blank. The name specifies how the window should be opened, is the second portion (tab, window, etc.).
This URL can't load local resources; therefore, "chrome:/newtab" won't function. If you try to use a period in your URL, it will open a new window with the last website you visited. If you try to start a new window with a slash in the URL, it will open with the base path of the new window. I tested invalid URLs (random strings and characters), and they merely opened a new window with your current URL and appended anything you wrote.
Sources for Reference
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Emad Baqeri |
| Solution 2 | |
| Solution 3 | K.K Desgins |
