Firefox addon: Window.open() vs CTRL-N - javascript

I created a simple firefox add on using addon-builder that installs & successfully appears in the add on toolbar at the bottom of the browser.
If I press ctrl-n, open new tab, open new window, or open private browsing window in firefox, then I see and can use my addon. However, if another site programmatically opens a window using window.open(), then my addon doesn't appear.
Is this by design? Or is there a setting that I can include in my addon so that it always appears, even if the window was opened through window.open() instead of ctrl-n?

When sites open with window.open, they specify which parts of the browser UI will show. You may be able to place it somewhere less likely to be removed, like the navigation toolbar. The add-ons toolbar sounds like it's going away soon, anyway.

Related

force window open in internet explorer

I guess what I want to do is not possible.
I would like open a new window using javascript, this is easy:
popup = window.open('www.google.es', 'titlebar=no,toolbar=no,location=no,status=no,menubar=no,resizable=no, top=0, left=0, type=fullWindow,fullscreen,scrollbars=yes');
but I want this new window opens in Internet Explorer whatever the parent was. So, I'm navigating in crhome, and opens the new window in IE.
Is it possible?
You can do it the other way around, that is force to open a link in Edge from an IE page,
window.open("microsoft-edge:http://www.google.com");
but it seems that it's not possible to use a similar command to force a link to open in IE.
It can be achieved using javascript and ActiveX (if enabled) but I can't use this in an enterprise environment (too risky)

Chrome/Safari: how to open the same window from different tabs or windows

In a web application, I have an optional popup window into which logging content is being loaded. This window is opened via Javascript using window.open().
The users typically have multiple tabs of the application open and my intention is to always reuse the same popup window (if currently open), no matter from which tab they trigger the popup. To do so, I use code similar to this to open the popup:
<script>
function myFunction() {
var myWindow = window.open("popup.html", "my_popup", "width=600,height=400,status,resizable");
}
</script>
This works fine in Firefox and IE - only a single popup window is ever opened and all content that I want to log is being loaded into that window.
Chrome and Safari however, use different popup windows depending on the tab from which the popup is launched.
I assumed that the second parameter of window.open() specifies a target name from a global namespace, which seems to be the case for most browsers. But Chrome and Safari behave as if there were tab-specific namespaces for these target names, i.e. "my_popup" referenced from tab 1 refers to a different target than "my_popup" from tab 2. (to make things more complicated, tabs that have been "duplicated" seem to share the same namespace, i.e. they do reuse the same popup window, but tabs created otherwise don't.)
Is there a way to circumvent this behavior of Chrome and Safari and access the same popup window from all tabs that the user may have open?
Or do I have to assume that this is browser-specific behavior for which there seems to be no workaround?
I have tested this with various browsers:
IE 11.0.9600.18204
All tabs with content from the same domain open/reload a single shared popup window (i.e the target namespace seems to be local per domain).
All tabs with content from file:// URLs reuse the same popup window as tabs with content from http:// URLs that point to the local intranet.
Firefox 46.0.1
All tabs with content from the same domain open/reload a single shared popup window (i.e the target namespace seems to be local per domain).
All tabs with content from file:// URLs use their own single shared popup window (i.e. file:// URLs seem to have their own target namespace).
Edge 20.10240.16384.0
The behavior is inconsistent: in most of my tests, Edge behaved like Firefox, but occasionally like Chrome as well.
I don't have a problem in ignoring Edge for the time being.
Chrome 50.0.2661.94
Each tab opens or reloads its own popup window (i.e the target namespace seems to be local per tab)
Safari 9.1
Each tab opens or reloads its own popup window (i.e the target namespace seems to be local per tab)
By the way, in all of these browsers the behavior does not depend on whether or not the popup window was launched due to user interaction: the behavior is identical between cases where the popup is launched via body onload() and cases where it is loaded via button onclick().
[here's additional background information that I assume not to be relevant to the problem, but who knows... ;-)
Actually, our application does not directly open the popup windows, instead we're using log4javascript which opens a logging window (or in case of Chrome: multiple logging windows). I'm willing to extend the log4javascript code to deal with this and send a patch to the maintainer, but in order to do so I need to solve the basic problem described above]

resizeTo() not working in Firefox

Running Firefox 12.0. I'm just starting to write a app that I want to run on localhost. I want it to open it in a (600,400) window, but since I have Firefox set to open everything in tabs I thought I could bookmark it and right-click to open it in a new window.
$(document).ready(function() {
window.resizeTo(600,400);
});
Doesn't work. Is what I am trying to do possible?
Thanks, Jim
This isn't possible, unless the window was opened through javascript using window.open and has only 1 tab in it.
Since Firefox 7, it's no longer possible for a web site to change the default size of a window in a browser, according to the following rules:
- You can't resize a window or tab that wasn’t created by window.open.
- You can't resize a window or tab when it’s in a window with more than one tab.
MDN docs

How to window.open with a toolbar in Google Chrome?

The following javascript opens a pop-up in Firefox, Safari, IE, and Google Chrome:
window.open("http://google.com", "foo", "toolbar=yes,location=yes,menubar=yes")
However, in Google Chrome the toolbar (with the usual forward and back buttons, etc.) does not appear on the popped-up window. (Tested on both Windows and Mac.)
How can I fix this? I would like the user to be able to navigate forward and back using the tools with which they are most familiar.
There is a bug open for Chrome:
https://code.google.com/p/chromium/issues/detail?id=82522
It has not received a lot of attention from Google. Vote for it.
Unfortunately Chrome only supports a small set of window features when using window.open. If you believe that this is a bug or an issue you can file it at [http://crbug.com].
If you just use window.open(url) then it will open a new tab in the same window with the buttons you desire.
Updating on current behavior (as of 4/26/2017)
The expected behavior should be a new PopUp Window when size dimensions are passed as arguments to window.open (if toolbar is enabled, then add the toolbar to the PopUp window). If no dimensions are indicated just default to opening a new tab (in this case toolbar enabled is the default).
(Btw, this is FF current Behavior (version 54.0a2)) .
Chrome Behavior (Canary 60.0.3079.0)
Opens PopUp Window to indicated dimensions
window.open("https://google.com","foo","width=800, height=780")
Opens New Tab (browsers default minimized size, ignores size dimensions)
window.open("https://google.com","foo","width=800, height=780,toolbar=1")
FF Behavior
w/Size Dimensions
Opens PopUp Window w/o ToolBar (NO toolbar)
window.open("https://google.com","foo","width=800, height=780")
Opens PopUp with ToolBar
window.open("https://google.com","foo","width=800, height=780, toolbar=1")
w/o dimensions
Opens New Tab
window.open("https://google.com","foo")
window.open("https://google.com","foo", "toolbar=1")
The only option for Chrome is to not specify a third argument. Chrome ignores the third argument as they are rightly allowed to do according to the HTML 5 specification, but if present the window appears to always open in a floating widow without controls.
If you do not specify a third argument the window that opens will be a new tab and will have all of the features the user needs.
If you do specify a third argument you will get a new floating window with no controls other than the URL display.
I know this is an old post, but the most recent answer is from September, 2013, so I am taking that as a reason to follow up with this answer. Advance apologies if this is not proper etiquette.
https://code.google.com/p/chromium/issues/detail?id=82522
That's the link to the bug over on the Chrome support page.
I am posting it here in the hope that others experiencing this problem will raise attention to this issue, as suggested in a previous answer.
My apologies for posting this comment as a separate answer. I don't have enough karma to do this the right way.

Open links in new tab in Firefox

I am developing an Firefox extension. How can all the links on a webpage to be opened in a new tab?
That's usually a configurable option in Firefox to handle new links, so they may override your extension with that.
However...
The code
Example Website
will allow you to click the appearing words [Example Website], and the link will open in the current window.
The code
Example Website
Opens the link in a new window/tab.
The only mildly dodgy thing is that target is now apparently deprecated by the W3C, which means that it's generally up to the browser ( and the user's preferences) as to how (or even if) it is handled. But for people who have their preferences set accordingly - in Firefox - that should work.
I found what I was after. I wanted gbrowser.addtab(this.href).
Press Ctrl while clicking on the link on Windows. Use cmd on OSX.

Categories

Resources