开发者

Maximizing the current window in javascript

Is there a way I can maximize a currently minim开发者_运维技巧ized 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!


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.


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();


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜