Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Toggle full screen view

The respondent can toggle between the full screen view and a smaller window by hitting F11.  Is there code that will allow my program to do it in v8.4.8?
asked Feb 19, 2017 by Mike (225 points)

1 Answer

+1 vote
You can try starting with something like this, but it's behavior is going to be very browser-specific:

<button type="button" id="fullScreenOn">Enter fullscreen</button>
<button type="button" id="fullScreenOff">Exit fullscreen</button>

<script>
$(document).ready(function(){
    $('#fullScreenOn').click(function(){
        var doc = document.documentElement;
        if (doc.requestFullscreen) {
            doc.requestFullscreen();
        }
        else if (doc.msRequestFullscreen) {
            doc.msRequestFullscreen();
        }
        else if (doc.mozRequestFullScreen) {
            doc.mozRequestFullScreen();
        }
        else if (doc.webkitRequestFullscreen) {
            doc.webkitRequestFullscreen();
        }
    });
    
    $('#fullScreenOff').click(function(){
        if (document.exitFullscreen) {
            document.exitFullscreen();
        }
        else if (document.mozCancelFullScreen) {
            document.mozCancelFullScreen();
        }
        else if (document.webkitExitFullscreen) {
            document.webkitExitFullscreen();
        }
    });
})
</script>


As an alternative, you could use the Sawtooth Script "PopUp" to create a nearly full screen window.
answered Feb 20, 2017 by Zachary Platinum Sawtooth Software, Inc. (91,200 points)
Sorry for being slow to answer.  Your answer works in Firefox but does not do it automatically.  Can it be made self-executing?  It seems there is a "resizeTo" command but browsers defeat it.
I'm not sure if that is doable.  Full screen capabilities are limited by browsers for reasons of security.
...