Results 1 to 2 of 2

Thread: Making current window full-screen using JavaScript

  1. #1
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,627
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default Making current window full-screen using JavaScript

    Hi,

    I wonder is there any method in JavaScript using which we can make the current window full-screen (the effect we get when we press F11 key in browser window). I am looking for a cross-browser solution (I know there is a activex based method using which it can be achieved for IE but I think the method seems to be bit offensive as far as Firewalls/Anti-viruses are concerned)

    regards

    Codex

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In modern browsers, nothing straightforward, really nothing at all that is fully cross browser. You can use the:

    Code:
    window.resizeTo(width, height);
    method coupled with the:

    Code:
    window.moveTo(left, top);
    method, using screen.availWidth and screen.availHeight as the width and height and 0 as the left and top. But many browsers can be set to not allow that. It is a user configuration. Some come with it already disallowed, the user would have to turn it on. Those that do allow it will 'do the math' slightly differently from one another, so it won't always be exactly like hitting F11 would be. Browsers will still allow this window to be restored, but some will think that it already is restored, so nothing will happen. This pisses off a lot of users when it happens to them - not being able to restore down their window in the accustomed manner, even after closing the browser session.

    Another approach is to have your page launch a new window of itself with the desired size. This is even trickier what with pop up blockers.

    You might be able to combine the two methods with tests to see if either is allowed/accomplished to see which to use. Even if everything works out, there will still be some chrome.

    However, it would probably be best to simply have a script that determines whether or not the window.innerWidth x window.innerHeight (document.documentElement.clientWidth and Height in IE) is already at or very near to the size of the user's screen.width by their screen.height, and if not, pop up an alert or have a large message appear on the page that advises them to ht F11.

    This has the advantage of being slightly less annoying than trying to take over the user's window by brute force.
    Last edited by jscheuer1; 09-07-2007 at 09:10 AM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •