How to toggle full screen using Javascript?

Posted on 2010-01-05
Last Modified: 2012-06-27
Is it possible to use Javascript to allow users to toggle a full screen option if they wish?

I've found some Javascript that I think tries to execute the F11 for Firefox.

Is it possible to check the browser then depending on what browser it is, if the user chooses to go full screen and click a link to execute e.g. F11?

(I'm not sure how this would be done in Safari. Chrome and Opera also use F11 for full screen.)
<script type="text/javascript">

function max()


var obj = new ActiveXObject("");





<body onload="javascript:max()">

Open in new window

Question by:Apari
    LVL 81

    Expert Comment

    Hello Apari,

    You can't take control on the web browser window with Javascript.


    Author Comment

    Hi leakim971,

    Thank you for your response. I've checked out the code I attached above and it does work (albeit with an Active X warning), linking the javascript to an onclick in a link.

    However it only works in IE. I'd like to know if there's a way to make it work with other browsers.
    LVL 81

    Expert Comment

    Have a look to this thread (you will find a lot on EE talking about full screen) :

    I know you hope something like use of ActiveX on FF or Chrome & Co. Perhaps try the latest version of Silverlight and FF...
    LVL 81

    Expert Comment


    Accepted Solution

    Okay I spent some time checking this out and it doesn't look like it's a possibility. The idea was to be able to toggle full screen using a link that would trigger the F11 key for full screen toggle which is initiated if you use F11 on the keyboard (FF/IE/Opera/Chrome). Would be an interesting solution especially if using jquery slideshows.

    LVL 9

    Expert Comment


    If you are interested in a solution which does not use F11 sendkey method, then please let me know and I will post the solution!
    LVL 4

    Expert Comment

    there are two javascript functions you can use:

    From w3:
    window.resizeBy() Resizes a window by the specified pixels
    window.resizeTo() Resizes a window to the specified width and height

    so you can use resizeTo(1024,800) where the numbers are the resolution of the client's monitor, there are some other properties that hold those values, I think they're called clientX or something like that, you can look that in

    to recognize the explorer you can use :

         // this code will only work in IE
         // everything else, opera and firefox are based on netscape so are really a like

    for chrome dont really know, havent really worked a lot with it

    there's also an object with the description of the browser: navigator.appName

    hope this helps

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
    I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now