2

Possible Duplicate:
How to make in Javascript full screen windows (stretching all over the screen)

Currently I tried to do something like, when you click a fullscreen button current window will become full screen. I tried to use the following script, but it doesn't work. Any ideas on how to make this work?

<script type="text/javascript">
window.onload = maxWindow;

function maxWindow() {
    window.moveTo(0, 0);

    if (document.all) {
        top.window.resizeTo(screen.availWidth, screen.availHeight);
    }
    else if (document.layers || document.getElementById) {
        if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
            top.window.outerHeight = screen.availHeight;
            top.window.outerWidth = screen.availWidth;
        }
    }
}
</script>
Community
  • 1
  • 1
Leon
  • 413
  • 2
  • 9
  • 23
  • i try to use window.open, but tat 1 open new tab. not really what i wan. – Leon Dec 01 '11 at 09:03
  • see [This question](http://stackoverflow.com/questions/1125084/how-to-make-in-javascript-full-screen-windows-stretching-all-over-the-screen) – Pradeep Dec 01 '11 at 09:06

2 Answers2

4

There's a new API supported by some of the newer browsers that'll let you make any element take over the whole screen:

See http://johndyer.name/native-fullscreen-javascript-api-plus-jquery-plugin/ for more info, including a jQuery plugin to use the feature.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
3

window.resizeTo has been disabled in modern browsers. You can only use it on your own popup windows.

https://hacks.mozilla.org/2011/09/whats-new-for-web-developers-in-firefox-7/ states:

Web sites can no longer resize your main browser window

It’s no longer possible for a web site to change the default size of a window in a browser, according to the following rules:

  1. You can’t resize a window or tab that wasn’t created by window.open.
  2. You can’t resize a window or tab when it’s in a window with more than one tab.
Roman
  • 5,888
  • 26
  • 47