user4951
user4951

Reputation: 33080

How to open window full screen using javascript

var windowprops = "width=1024,height=768,location=yes,toolbar=yes,menubar=yes,status=yes,scrollbars=yes,resizable=yes,top=1,left=1";
var url = "http://silverslady.net/silver/silverbrazil.php?mn=5343";
var myWin = window.open(url, '', windowprops);
myWin.blur();
window.focus();
return true;

That's the code to open window. What about if I want to open it full screen

Upvotes: 0

Views: 4860

Answers (1)

sbozzie
sbozzie

Reputation: 727

<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> 

Something like this in the page to be loaded. It's generally considered bad practice to resize browsers without notice really.

You might want to read up on https://developer.mozilla.org/en-US/docs/Web/Guide/DOM/Using_full_screen_mode this guide to the fullscreen api.

Upvotes: 2

Related Questions