I'm using Javascript's self.open()
to open a link in a new window and i'd like that window to be maximized. I tried the fullscreen=yes
option, which really doesn't do what I want. I am using below code:
self.open(pageLoc,popUpName,'height=1600,width=1800,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');
If i also mention fullscreen=yes
, then window opens up like you press F11. But i don't want it that. What i want is when i double click on IE and click maximize icon on top right corner.
As i have given the height
and width
value so large, it is close to maximized window but not actual maximized window. (the reason i am saying this because
even now if i click maximize button, it further expans little bit)
Please refrain from opening the popup unless the user really wants it, otherwise they will curse you and blacklist your site. ;-)
edit: Oops, as Joren Van Severen points out in a comment, this may not take into account taskbars and window decorations (in a possibly browser-dependent way). Be aware. It seems that ignoring height and width (only param is
fullscreen=yes
) seems to work on Chrome and perhaps Firefox too; the original 'fullscreen' functionality has been disabled in Firefox for being obnoxious, but has been replaced with maximization. This directly contradicts information on the same page of https://developer.mozilla.org/en/DOM/window.open which says that window-maximizing is impossible. This 'feature' may or may not be supported depending on the browser.Checkout this jquery window plugin: http://fstoke.me/jquery/window/
The best solution I could find at present time to open a window maximized is (Internet Explorer 11, Chrome 49, Firefox 45):
see https://jsfiddle.net/8xwocrp6/7/
Note 1: It does not work on Edge (13.1058686). Not sure whether it's a bug or if it's as designed (I've filled a bug report, we'll see what they have to say about it). Here is a workaround:
Note 2:
moveTo
orresizeTo
will not work (Access denied) if the window you are opening is on another domain.If I use Firefox then
screen.width
andscreen.height
works fine but in IE and Chrome they don't work properly instead it opens with the minimum size.And yes I tried giving too large numbers too like
10000
for bothheight
andwidth
but not exactly the maximized effect.