问题
On typing chrome://newtab
or about:newtab
in Google Chrome's Address Bar, we can explicitly open a new tab.
How can we do the same from a Web Page ?
I tried it on a hyper-link, like <a href="chrome://newtab" target="_blank">Click to open the Chrome's 'New Tab' page</a>
, but it doesn't work..
I even tried using JavaScript using window.open('chrome://newtab','_newtab')
and redirection using window.location = chrome://newtab
, neither worked..
Is there any way to achieve this from a Web page, like by clicking or redirecting to the newtab ?
Hope my question is clear now.
回答1:
The best you can do to open a new tab, is open a blank page.
Colon's are required to open urls like chrome:newtab
:
var win = window.open('http://chrome:newtab', '_blank');
but they are not allowed in any url:
A colon is reserved and may not be used unencoded except for its special purpose (which depends on the scheme). Section 2.2:
Many URL schemes reserve certain characters for a special meaning: their appearance in the scheme-specific part of the URL has a designated semantics. If the character corresponding to an octet is reserved in a scheme, the octet must be encoded. The characters ";", "/", "?", ":", "@", "=" and "&" are the characters which may be reserved for special meaning within a scheme. No other characters may be reserved within a scheme.
Even if you try to encode it:
var win = window.open('http://chrome%3Anewtab', '_blank');
Chrome will not allow you to do that. You most likely already saw:
Unable to open a window with invalid URL 'http://chrome:newtab/'.
Chrome will allow you to use colons, but only as parameters. Look at the example below, and note the question mark in the second url.
rejected
var win = window.open('http://something.com%3Apro', '_blank');
permitted
var win = window.open('http://something.com?%3Apro', '_blank');
回答2:
In hyperlink, you need to put target="_blank" in the a balise.
来源:https://stackoverflow.com/questions/37596150/how-do-i-open-the-new-tab-page-explicitly-in-chrome-from-a-web-page