views:

102

answers:

2

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!

+1  A: 

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
A: 

You should not resize the browser window, it's considered intrusive.

Instead, I recommend monitoring the size of the window and gently (show a div, don't alert a message) notifying the user with something like "Please resize your window to enjoy the best experience etc etc"

nc3b
Trust me that this isn't something I WANT to do. It's a client request.