On Windows press Alt + D then Shift + Enter
On Mac press Command + L then Shift + Enter.
Alt + D or Command + L to select the URL. Shift + Enter to open the URL in a new window.
Answer from SGventra on Stack ExchangeOn Windows press Alt + D then Shift + Enter
On Mac press Command + L then Shift + Enter.
Alt + D or Command + L to select the URL. Shift + Enter to open the URL in a new window.
Alt + D : to select the URL.
Then, if you want a new tab use: Shift + Enter + Alt
If you want a a new window use: Shift + Enter
How to launch a new window in Google Chrome Extension
Chrome Extension: How do i open urls in popup.html in the same tab - Stack Overflow
Chrome extension: How to open a link in new tab?
How to make new tabs open in the same positions as in Chrome?
Videos
First off, if you have a default_popup defined in the manifest - you need to remove it, as it interferes with the click event you want to catch.
Then, you need to catch the event in a background script:
chrome.browserAction.onClicked.addListener(function(tab) {
// ...
});
Next, if we want a window, we probably want to look at the windows API. create() sounds like what you need:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({/* options */});
});
What options do you need? Assuming you want to open a page from your extension, you'll need an URL wrapped in a chrome.runtime.getURL:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({
// Just use the full URL if you need to open an external page
url: chrome.runtime.getURL("mypage.html")
});
});
Then, to show a window like you're showing, without top toolbar, you need a window type "popup":
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({
url: chrome.runtime.getURL("mypage.html"),
type: "popup"
});
});
Finally, if you want to do something after the window has opened, use the callback:
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.windows.create({
url: chrome.runtime.getURL("mypage.html"),
type: "popup"
}, function(win) {
// win represents the Window object from windows API
// Do something after opening
});
});
background.js
chrome.browserAction.onClicked.addListener(function(activeTab)
{
chrome.windows.create({ url: chrome.runtime.getURL("popup.html"), type:
"popup" });
});
manifest.json
{
"manifest_version": 2,
"name": "",
"description": "",
"version": "1.0",
"chrome_url_overrides": {
"newtab": "popup.html" //the html to show in popup
},
"browser_action": {
"default_icon": "img/zi.png" //some icon
},
"permissions": [
"tabs"
],
"background": {
"scripts": ["background.js"],
"persistent": false
}
}
I believe that chrome does not allow the popups to open an external page by any way. The only solution I know is to place an iframe in your popup.html file with src attribute set to popup2.html and place all your html inside popup2.html. However, consider that all websites do not work well inside iframe.
If you are trying to open url in currently active tab then try following:
Attach following script to your popup.html file:
var hrefs = document.getElementsByTagName("a");
function openLink() {
var href = this.href;
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
var tab = tabs[0];
chrome.tabs.update(tab.id, {url: href});
});
}
for (var i=0,a; a=hrefs[i]; ++i) {
hrefs[i].addEventListener('click', openLink);
}
You need to add tabs permisson to your manifest file for this to work.
You only need to use chrome.tabs.update({active: true, url: 'yoursite.com'}); instead of chrome.windows.create({url:'yoursite.com'}); and the location will be opened in the same active tab
The problem is that you are violating manifest version 2's content security policy. To fix it all you have to do is get rid of inline script, in this case your background page. Turn it into a background script like this:
manifest.json
"background":{
"scripts": ["background.js"]
},
background.js
chrome.browserAction.onClicked.addListener(function(activeTab){
var newURL = "http://stackoverflow.com/";
chrome.tabs.create({ url: newURL });
});
If, for some reason, you do need it to be a page, then simply include the script as an external file and declare it as a page like before.
In my case I needed to open link in a new tab when I clicked a link within extension popup window, it worked fine with target attribute set to _blank:
<a href="http://www.example.com" target="_blank">Example</a>
There are two possible ways to achieve this:
1 - When the new tab open it will always opens in the chrome window which is last active or last minimized, means you have to open two chrome's window and always have to active the window in which you want to have your new tabs to open.
2 - You have to install different browser so that you don't have to care the active chrome's window.
That's all you can do.
I know it's been a while but opening the first window as a popup using simple HTML does it:
<a href="http://www.google.com"
target="popup"
onclick="window.open('http://www.google.com','popup','width=600,height=600'); return false;">
Link Text goes here...
</a>
I just switched to Firefox due to all the good things I've been reading about this program, and it has been really good, but I just can't get used to how each time I open a new tab, it goes to the end of the list of tabs that I have opened from the current tab.
In Chrome, when you open a bunch of tabs from a single site/tab (A), each one gets positioned after the previous one (B,C,D), but if you click another tab (Z) and go back to (A), the next tabs you open from there will be located before B, C and D, like (E,F,G,B,C,D).
Meanwhile, in Firefox you always get B,C,D,E,F,G by default and I don't like that because in some sites, like YouTube (or any time I research something), I have a main tab from which I open a bunch of new ones, and tabs just keep opening further and further away, even if I think the new ones should have priority (should be closer to the parent tab).
I thought " browser.tabs.insertAfterCurrent" would help me with that but it didn't. I am currently using "Tree Style Tab" plugin to help me navigate my tabs, and it says it has the option I'm looking for, but it's not working.
So, is there a way to have that Chrome behavior when opening tabs? I'm doing things wrong?
Some websites open links in a new tab, and I find this incredibly annoying. Is there any way to force links to open in the same tab, instead of opening a new one?
Problem
For Linux, if you have multiple VNC servers, this same problem will occur.
That is,
$ google-chrome
Created new window in existing browser session
And no google chrome window will appear in the current X VNC session (a new tab will appear in the X session with the first instance of google-chrome).
Solution
A simple workaround is to run
$ google-chrome "--user-data-dir=${HOME}/.google-chrome/session${DISPLAY}"
This sets a unique user directory based on the X VNC instance in use. The user directory will be created as needed. The new google-chrome process will display within the current X VNC session.
Tested using Google Chrome version 22 on Ubuntu 12.04.
There doesn't appear to be a user-friendly option to change this inside Chrome (presumably because most people prefer the new tab).
However, you can change this manually by editing the command specified in your Windows registry used to open an http url.
To do this, open regedit and:
- Go to
HKEY_CLASSES_ROOT\http\shell\open\command - You should see one key, named
(Default). Double click this to get an editing popup. - At the end of the
Value data:field you should see the text-- "%1". Change this to--new-window "%1".
That will instruct Windows to open all http links in a new window of Chrome instead of a new tab.
Presumably, the same general idea is true for Mac and Linux, but I don't know offhand where they store the command to open urls.
Looking for a solution to force any links to open in the same window of the chrome browser instead of opening in a new window.
Holding Ctrl+Left click doesn't work for all kinds of links.
"Open link in the same tab, pop-up as tab" extension doesn't work on some links.
Yes, a popup page is just a normal extension page, you can do the following to open a new popup tab from the background page. I use that every time when the user first installs the extension, I open the about page, you can do the same for the popup page.
chrome.tabs.create({url: 'popup.html'})
For one of my extensions, My Hangouts, I have a small "open as tab" button within the popup, I bind the click event for that link to execute this:
chrome.tabs.create({url: chrome.extension.getURL('popup.html#window')});
The reason why I passed the hash is because I wanted to add more content when the user opens it in a popup because there is more real estate to play with.
Within the popup, I use normal JavaScript to differentiate whether I opened the tab in the new tab page or in a normal page like the following:
if (window.location.hash == '#window') {
this.displayAsTab = true;
}
You can do tricks like this to make your extensions user experience better.
here is the same issue: Chrome Extension: onclick extension icon, open popup.html in new tab
use:
chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) {
// Tab opened.
});
property "pinned" to stick the tab.