FF not setting size on window.open - javascript

I have a simple JS script including:
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
FF 21.0 opens it to the full size of the browser window.
Chrome and Opera correctly open it to the specified width and height.
Is this a known bug in FF? Is there some way around it?

You need to remove the space between height and width in your third argument.
See strWindowFeatures # MDN
Update:
As Pointy says, this doesn't seem to be the case (and from some testing it certainly doesn't affect me in FF 24). However, quoting from Firefox's tab preferences and settings page:
If you have chosen to open pages in new tabs, Firefox will ignore this option and will open a new window from a link if the page author specified that the new window should have a specific size, because some pages can only be displayed correctly at a specific size.
So this must have been changed from FF 21 til now. How are you triggering the window.open? I know some browsers differentiate based on event source, meaning you get different results on triggering it in Javascript vs. from a user-initiated event.

Voila! Pointy had the answer.
I hadn't noticed that the window was opening in a new tab.
I unchecked the browser open-in-a-new-tab option, and now I get the properly-sized window.
Thank You!

Related

Window.open doesn't work when original window size is specified

I have a script that opens a chrome window like so chrome.exe --user-data-dir="%LOCALAPPDATA%\Google\Chrome\User Data\" --window-size=1280,118 --window-position=0,0 --app="file:///C:/desktop/test.html" I need to open another smaller popup window from that window but the popup always opens in the same size as its parent (1280x118). I have tested using window.open('','','resizeable, width=100,height=200') from a regular chrome window and it works as expected. It seems that window.open does not respect the width and height specified if it is launched from a window with a specified window-size. Are there any alternatives to window.open? Or does anybody know how to make this work in Chrome? Its working fine in IE but want to phase out IE for obvious reasons.
I made this work by setting window.open to a variable and then using window.resizeTo to change its size.
var myWindow=window.open('','newWin','width=200,height=100');
myWindow.resizeTo(200,300);
myWindow.moveTo(500, 100);
myWindow.focus(); ```

In Firefox the window is not re-sizeing using JavaScript,

I have a JavaScript to re-size all my popup windows:
function resize()
{
window.resizeTo(240,230);
}
But now it is not resizing in Mozilla Firefox, but it was doing earlier, also
or if the popup window is opened in a new tab, it is not resizing, also in some browsers it is not also. Is there any piece of JavaScript code which works in all scenarios and all browsers?
Firefox comes with a preference for user to allow/disallow resizing of
window using Javascript. It's in Tools - Options - Content - Enable
Javascript -> [Advanced].
I am not sure if resizing is disabled by default, but you might want
to check your own Firefox installation first.
If it's disabled by default, then unfortunately there is nothing you
could do to resize the window after it has been opened. An ugly
workaround would be to open itself once again using window.open() with
the preferred size though.
Source: timdream (here)
I'll also add that:
You can't be assured that any browser will let you control the size of
windows you create. You can't even be sure you'll get a window at all
- people can instruct their browsers to open all new windows as browser tabs
Source: Pointy (same source as timdream)

Window.open opening tab instead of popup in Opera?

I'm simply opening a popup from JavaScript with the settings you can see in the code. Works fine in Firefox. In Opera it's opening it in a new tab instead. Why?
Here's a JSFiddle:
http://jsfiddle.net/hafWs/3/
The number of parameters doesn't seem to make a difference. Either work in Firefox and IE8. (Don't have IE9 or Chrome to test right now.)
I tried googling... can't find anything. I don't even see anything here that mentions it, yet it's clearly working in their examples: http://www.quirksmode.org/js/popup.html
Thank you for any help.
There is problem with spaces in options param:
window.showPopup = function(){
window.open(
'http://placekitten.com/600/500',
'thePopup',
'width=600,height=500' /* <------- Look, no spaces and works */
);
}
It is still a tab, but with different dimensions. So, it looks kinda as popup.
This is controlled by the browser itself (preferences) and cannot be changed from JavaScript.
NOTE: I've seen some posts that say you can determine whether the window opens in a tab or as a new window based on the parameters that you pass the window.open function. I have never seen this work consistently.

JavaScript: Forcing IE into opening new tab instead of window?

I want a script that makes a user's Internet Explorer open a new tab instead of a new window whenever someone clicks on a (target="_blank") link/banner on my webpage.
I hate how Internet Explorer defaults to opening new windows instead of new tabs when a link/banner is clicked. All the other popular browsers (e.g. Chrome, Opera, Firefox) open tabs by default.
Preferably this script would need to work in all versions of IE that support tabs.
So... How to, using JavaScript force IE into opening new tab instead of window, which is it's default behaviour?
This isn't possible; it's a browser setting/behavior which is not callable from a script loaded on the page.
Programmatically open new pages on Tabs
In IE11 at least, the default user setting is to 'Let Internet Explorer decide how popups should open' (Off-hand, I'm not sure what the default was in previous versions). Some context around the IE behaviour with this default setting can be found here: https://superuser.com/questions/713743/what-rules-apply-when-ie9-decides-how-to-open-popups
Per others' answers/comments here, generally speaking, we as web programmers have little control over how popups are opened. However, provided users have not changed their default selection (in IE11 at least!), you can approximate the behaviour you want through appropriate invocation of the window.open() method. Specifically, if you pass less than three arguments to the method, IE will generally open a new tab, while passing the specs (third) argument (even if with a null or undefined value <- this caught me out initially!) results in IE popping a separate window.
If you're happy to live with a solution that isn't guaranteed but works a fair amount of the time, this may help. The 'tyranny of the default' works in our favour in this instance at least!
Chrome at least is not quite so picky about the specs argument - if null or undefined, it will pop the tab instead of the window under default configuration.
What I did was to go to the tab settings of IE and under the section 'When a pop-up is encountered' select 'Always open pop-ups in a new tab'. I hope this helps.
To navigate to this menu open IE settings (Cog icon at the top-right, Internet Options) and click the tabs button under the Tabs section.
The below post show you how to navigate to the menu in the screenshot.
https://superuser.com/questions/507798/prevent-a-single-ie-window-with-multiple-open-tabs-from-being-displayed-as-multi
IE Settings

toggling fullscreen mode with javascript with firefox add-on

The firefox add-on I am working on is best viewed in fullscreen mode. (I am not creating a new window, but I insert a transparent div on the body of the current page and display some pictures.) Is there a way to toggle the fullscreen mode or f11 key with javascript?
Thanks in advance,
According to https://developer.mozilla.org/en/DOM/window.fullScreen, you should be able to just do window.fullScreen = true; (provided that your script is running in the browser window, not some other window, in which case you may have to jump through a couple hoops to get a reference to the main browser window)
This property indicates whether the
window is displayed in full screen
mode or not. It is only reliable in
Gecko 1.9 (Firefox 3) and later, see
the Notes below. With chrome
privileges, the property is
read-write.

Categories