2

I am working on a Flash app that is 900x700 pixels. When viewed in misc. browsers at 1024x768, the browser chrome causes robs too much of the vertical space and the app appears in a window with a vertical scrollbar. Unacceptable.

The flash app will be launched via a link emailed to the viewers.

I'd like to avoid resizing the flash app and am wondering if there's a way to do the following via javascript, with no clicks involved:

  1. maximize the current browser window
  2. remove current window address bar and tabs / switch browser to full screen view (equivalent to pressing F11).

An alternative would be to resize the flash app vertically to match the browser canvas height to avoid scrolling. This may cause the app to become unreadable, so not the best approach in my case.

Thank you!

UPDATE: Seems that browser resizing and autoswitch to full screen won't work and neither will the flash app auto resize. What is the best approach then? And, some users may have browsers with toolbars or open a small browser window.

The only idea I have is to use javascript and display a message to users with small browser windows to pres F11 manually. The audience is executes and some may not even know what an F11 means...

aaandre
  • 2,502
  • 5
  • 33
  • 46
  • OK, seems unlikely this will happen through the browser. Any chance to have a button in the flash app allowing for user to enter full screen? Like the YouTube full screen but for the whole flash app? – aaandre Jan 23 '10 at 00:45
  • Don't do it. Please. It's intrusive. - Sincerely, your users. – metrobalderas Jan 23 '10 at 01:33
  • Most of the answers in this thread addressed the issue and brought value. I could only mark one as the answer. Thank you to everyone who contributed! – aaandre Jan 25 '10 at 18:39
  • This question appears to be a duplicate of http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen – Anderson Green Jun 03 '13 at 23:55

5 Answers5

4

There is no way to maximize the browser window to full screen with JavaScript. While this is unfortunate for your genuine requirement, it is considered a security restriction.

Sources:

Community
  • 1
  • 1
Daniel Vassallo
  • 337,827
  • 72
  • 505
  • 443
2

The window size can be altered by using:

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

You can use JavaScript to open a new window (using window.open) and control the window that is opened (no address bar, etc). You can also control the size of the window (you can't maximize it, but you can get the users screen size, and set the window that same size).

Gabriel McAdams
  • 56,921
  • 12
  • 61
  • 77
  • Browsers tend not to allow you to remove the address bar these days (and an anti-phishing measure) – Quentin Jan 23 '10 at 00:49
1

To answer the question in the comment you made to your own post. Yes. You can have a button whose click handler does this

stage.displayState = StageDisplayState.FULL_SCREEN;
sberry
  • 128,281
  • 18
  • 138
  • 165
  • So, this would resize the stage to full screen? I am wondering then, would it be able to restrict the scaling of the application portion and resize a background to full screen while maintaining the intended size for the app? I guess I am asking to resize the background of the app but restrict the up-sizing of the active portion of the canvas. – aaandre Jan 23 '10 at 01:58
  • Yes, stage.scaleMode = StageScaleMode.NO_SCALE will maintain the size of the app. The rest of the screen would be filled with the background color of your app. – Lars Blåsjö Jan 24 '10 at 13:10
1

Chrome 15, Firefox 10, and Safari 5.1 now provide APIs to programmatically trigger fullscreen mode. Fullscreen mode triggered this way provide events to detect fullscreen changes and CSS pseudo-classes for styling fullscreen elements. These APIs may present you with a more acceptable solution for those browsers.

See this hacks.mozilla.org blog post for details.

Simon Lieschke
  • 13,058
  • 6
  • 46
  • 60