Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open maximized window with Javascript?

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)

like image 259
M Sach Avatar asked Apr 24 '12 11:04

M Sach


People also ask

How do I get a program to open in maximized window?

In the Properties window, click the Shortcut tab (A). Locate the Run: section, and click the down arrow on the right side (red circle). In the drop-down menu that appears, select Maximized (B). Click Apply (C), and then click OK (D).

How do you maximize a pop up window in HTML?

self. open(pageLoc,popUpName,'height=1600,width=1800,resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes');


2 Answers

var params = [     'height='+screen.height,     'width='+screen.width,     'fullscreen=yes' // only works in IE, but here for completeness ].join(',');      // and any other options from      // https://developer.mozilla.org/en/DOM/window.open  var popup = window.open('http://www.google.com', 'popup_window', params);  popup.moveTo(0,0); 

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.

like image 70
ninjagecko Avatar answered Sep 30 '22 15:09

ninjagecko


 window.open('your_url', 'popup_name','height=' + screen.height + ',width=' + screen.width + ',resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,location=yes') 
like image 44
silly Avatar answered Sep 30 '22 16:09

silly