7

Is there a way I can maximize a currently minimized window from Javascript? Here's my situation:

I have a series of links that all target the same external window (e.g. "MyNewWindow"). When I click a link, a new window pops up. If I click another link, the page pops up in the same window as expected. If I minimize the "MyNewWindow" popup, I'd like to be able to click another link and have that window maximize.

My approach was to put something on the onLoad part of the body so that when the page is refreshed it will automatically "maximize" if it is minimized. Note: Using window.MoveTo() and window.resizeTo() doesnt seem to do the trick (the window stays minimized).

Thanks!

Ka Wai Cheung
  • 241
  • 1
  • 2
  • 11
  • 5
    Please don't resize my windows. I use a tabbed browser and such behaviour screws with everything else, too. – ceejayoz May 24 '10 at 16:57
  • This sounds really annoying: *when the page is refreshed it will automatically "maximize" if it is minimized* – nc3b May 24 '10 at 16:59
  • This sounds like a very good reason *not* to have a load of links target an external window. It's not 1998 any more. – bobince May 24 '10 at 17:47

3 Answers3

13

For all of you know-it-alls, there are perfectly good reasons to want to know how to do this. Here's the reason I needed this:

  • I'm deploying SCORM modules to a variety of Learning Management Systems (LMSs)
  • One LMS that a client is using launches the module in a small (600x400) window, with the user controls to maximize or resize said window DISABLED
  • The client doesn't know how to change this launch behavior

My only option is to try to maximize via javascript, because the idiots who made the LMS took away the user's ability to manage their own windows.

window.moveTo(0, 0);
window.resizeTo(screen.availWidth, screen.availHeight);

This may not work in IE depending on the security zone your page is falling under, and it may not work in Chrome at all. But for a corporate environment in an intranet, it has a good chance of working.

jrb
  • 381
  • 3
  • 6
  • It might be better to use "window.moveTo(screen.availLeft, screen.availTop);" if you can. 0,0 would automatically move it to the primary window also. – OrangeKing89 Oct 07 '19 at 18:32
3

Don't do this, you are not allowed to do this by most modern browsers for a reason.

In a tabbed environment you're not messing with only the window you may have created, but all of my tabs, that's unacceptable. It's the user's computer, user's browser, it's the user who chose to go to your site...let them size the window the way they want it, doing anything else breaks their experience...and their trust in your site.

The behavior you're looking to emulate is what your run-of-the-mill malware does...re-think your approach, please. For example focusing that window is appropriate for what you want, let the default behavior of the browser take over from there, like this:

var thatWindow = window.open(url, "linkWindow");
thatWindow.focus();
Nick Craver
  • 623,446
  • 136
  • 1,297
  • 1,155
-1

try to use window.open(url,fullscreen=yes); if you out fullscreen=yes than while clinking on link automatically

Hitesh Kumar
  • 45
  • 1
  • 14
  • if you use fullscreen=yes than while clicking on link automatically maximize window open in maximize sie – Hitesh Kumar Nov 19 '13 at 06:03
  • 2
    Does not work (IE, Firefox, Chrome). Also: 2nd parameter of `window.open()` is window name, so you're setting the name to "fullscreen=yes". Window features should be the 3rd parameter. – Kidquick Jul 19 '19 at 14:15
  • I'm also assuming you meant window.open(url, "", "fullscreen=yes") which doesn't work for me (Chrome) – aljgom Jun 06 '22 at 02:21