0

有一个简单的问题给你,但对我来说仍然很难......我想做的就是用不同的按钮最大化新的打开的窗口......但它不起作用,无法弄清楚为什么......有人可以请告诉我,我做错了什么?

<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();
    }
4

1 回答 1

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

我将此添加到第一个函数'fullscreen = yes'并在第二个函数中用我的代码更改第二行 maxWindow.resizeTo(screen.width, screen.height);

于 2013-09-07T18:19:38.083 回答