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.
Answer from JamesThomasMoon on Stack ExchangeProblem
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.
Videos
Clicking on the links and selecting "Open in New Window" is slowing me down. Its a repetitive task and the seconds are adding up.
I looked for a solution but could not find one.
That will open a new window, not tab (with JavaScript, but quite laconically):
<a href="print.html"
onclick="window.open('print.html',
'newwindow',
'width=300,height=250');
return false;"
>Print</a>
With pure HTML you can't influence this - every modern browser (= the user) has complete control over this behavior because it has been misused a lot in the past...
HTML option
You can open a new window (HTML4) or a new browsing context (HTML5). Browsing context in modern browsers is mostly "new tab" instead of "new window". You have no influence on that, and you can't "force" modern browsers to open a new window.
In order to do this, use the anchor element's attribute target[1]. The value you are looking for is _blank[2].
<a href="www.example.com/example.html" target="_blank">link text</a>
JavaScript option
Forcing a new window is possible via javascript - see Ievgen's excellent answer below for a javascript solution.
(!) However, be aware, that opening windows via javascript (if not done in the onclick event from an anchor element) are subject to getting blocked by popup blockers!
[1] This attribute dates back to the times when browsers did not have tabs and using framesets was state of the art. In the meantime, the functionality of this attribute has slightly changed (see MDN Docu)
[2] There are some other values which do not make much sense anymore (because they were designed with framesets in mind) like _parent, _self or _top.
Hold the SHIFT key and left-click the link; the link will open in a new window.
I wrote a script to do this, then I set my default application in system preferences to this script for web links, works for me but not reliably and I welcome any/all better answers. I haven't found anything better in the years I've been using this though
http://smoove-operator.blogspot.com/2011/06/open-links-from-external-applications.html
Weird one. We have a user and for some reason on two specific sites, when she logs into her account for the site, it opens a new Chrome window, not tab as it should but completely new and separate window. I can’t find anything on this issue. Weird thing is we operate in a VDI environment. I’ve gone as far as logging her out and completely wiping her Chroming folder from her UEM profile. This in theory should push any of her chrome settings back to default. However, issues continues. Again, it’s only for two specific sites and it’s not when she opens the site but rather when she logs into the site. Anyone seen this before? There are no chrome settings that I could find that relate to this.
Some sites have user preferences for this and some are hard scripted to open a new window. In my older days of web design we used to hard code it all the time.
Some (poorly designed) sites I use for work have "open as new browser window" (pop-up medium sized window) as a policy for some links.
In firefox, there's an under the hood option that solves this and forces every attempt of new window opening to be converted to new tab: browser.link.open_newwindow.restriction = 0.
I've been away from Chrome for some time, but was using it today and noticed I couldn't achieve what that command does in firefox.
Is there a way, extension aside, that forces all new window attempts to be converted to tabs?
I spent some time searching for this topic and found nothing working on the web.
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.
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
i think the problem is in the second argument. check this. name - The name of the window (Note: the name does not specify the title of the new window)
Could you try this code please?
function openWindow(url, title) {
var myWindow = window.open(url, title, "height=640,width=960,toolbar=no,menubar=no,scrollbars=no,location=no,status=no");
}
Working example: https://jsfiddle.net/C0dekid/go96uk5r/5/
If your popup is created by a direct user action (not blocked by the popup blocker) and using the default options it will open in a new tab. If you create it programmatically, it will open as a new window. There is no way to change this behavior.
What you can do, although it is a really bad hack, is create the popup on a user action and then set the location to the final destination using a reference to the popup later on, like the following:
<a href="javascript:;" id="testAnchor" />
var popup1 = null;
document.getElementById('testAnchor').onclick = function() {
popup1 = window.open('about:blank', 'popup1');
}
setTimeout(function() {
popup1.location = 'LOCATION_ON_THE_SAME_ORIGIN_AS_THE_OPENER';
}, 5000);
Chrome Add on "One Window": https://chrome.google.com/webstore/detail/one-window/papnlnnbddhckngcblfljaelgceffobn
Automatically moves new Windows and Popups as Tab to the Main-Window. So it is never more than a single Window open.
This is a trick,
function openInNewTab(url) {
window.open(url, '_blank').focus();
}
// Or just
window.open(url, '_blank').focus();
In most cases, this should happen directly in the onclick handler for the link to prevent pop-up blockers, and the default "new window" behavior. You could do it this way, or by adding an event listener to your DOM object.
<div onclick="openInNewTab('www.test.com');">Something To Click On</div>
Reference: Open a URL in a new tab using JavaScript
Nothing an author can do can choose to open in a new tab instead of a new window; it is a user preference. (Note that the default user preference in most browsers is for new tabs, so a trivial test on a browser where that preference hasn't been changed will not demonstrate this.)
CSS3 proposed target-new, but the specification was abandoned.
The reverse is not true; by specifying certain window features for the window in the third argument of window.open(), you can trigger a new window when the preference is for tabs.
i had an extention that forced links to open in a new tab in the current window.
it stopped working today because chrome suddenly "registers" it as "harmful" extention.
does someone have a solution to this?
You can try:
var tab=window.open("Download.php",'_blank');
tab.focus();
Steps to verify
create a html file with markup:
<html>
<body>
<script>
function newTab(){
var tab=window.open("http://conceptf1.blogspot.com/2013/11/javascript-closures.html",'_blank');
tab.focus();
}
</script>
<a href="#" onclick="newTab()">Open Tab</a>
</body>
</html>
Open it in chrome and click the link.
Short answer: you can't. At least for now, the browser vendors view this as something that should strictly be left to users to define for themselves. You set your target to something that should be a new window, and the browser will use the user's preferences to decide whether it opens as a new window or a new tab.
Long answer: There's a CSS property that would do this on the HTML side, but none of the browsers support it. According to the proposal, you'd use target-new: tab for links that you explicitly want to open in a new tab, and target-new: window for those you want to open in a new window. I don't know of any DOM proposals to do something analogous to this on the JavaScript side.
There is no way to do that as the author of the HTML that a browser renders. At least not yet that I know of. Its pretty much up to the browser and its settings / preferences that are set by users themselves.
Also, you shouldn't impose this upon any user. A browser is the user's property. If a user wants to open all links in tabs or in new windows, then let the user do exactly that.
It's good that we can't do certain things. target=_blank is still abused and popups have been done to death.
Since I fell into this old question and then found that it is now possible (maybe this css option wasn't available then), I just want to add an update on how it can be done:
<a href="[yourlink]" target="_blank" style="target-new: tab;">Google</a>
Here are the options for the target-new style:
target-new: window | tab | none
Didn't test the none option, maybe it uses the default browser setting.
I confirmed this for Firefox and IE7-9.