MrPaulius
MrPaulius

Reputation: 107

js function wont work

Got one easy question for you, but still hard for me... All i'm trying to do, is maximize new, opened window with different button...But it doesn't work, cant figure out why .. can someone please tell me, what i do wrong?

<form>
    <input type="button" value="Create New Window" onclick="createWindow()" />
    <input type="button" value="Maximize New Window" onclick="maximizeWindow()" />
</form>

var maxWindow;
    function createWindow(){
        var winWidth = 300;
        var winHeight = 100;
        var winLeft = (screen.width - winWidth)/2;
        var winTop = (screen.height - winHeight)/2;
        var winOptions = ",width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop;
        maxWindow = window.open("http://www.google.com","newWindow",winOptions);
        maxWindow.focus();
    }

    function maximizeWindow() {
        maxWindow.moveTo(0,0);
        maxWindow.resizeTo(screen.availWidth, screen.availHeight);
        maxWindow.focus();
    }

Upvotes: 0

Views: 200

Answers (1)

Ankit Agrawal
Ankit Agrawal

Reputation: 6124

<script>
var maxWindow;
    function createWindow(){
        var winWidth = 300;
        var winHeight = 100;
        var winLeft = (screen.width - winWidth)/2;
        var winTop = (screen.height - winHeight)/2;
        var winOptions = ",width=" + winWidth + ",height=" + winHeight + ",left=" + winLeft + ",top=" + winTop+'fullscreen=yes';
        maxWindow = window.open("http://www.google.com","newWindow",winOptions);
        maxWindow.focus();
    }

    function maximizeWindow() {
        maxWindow.moveTo(0,0);
        maxWindow.resizeTo(screen.width, screen.height);
        maxWindow.focus();
    }
</script>
<form>
    <input type="button" value="Create New Window" onclick="createWindow()" />
    <input type="button" value="Maximize New Window" onclick="maximizeWindow()" />
</form>

i add this to first function 'fullscreen=yes' and in second function change second line with my code maxWindow.resizeTo(screen.width, screen.height);

Upvotes: 1

Related Questions