0

あなたにとって簡単な質問が1つありますが、それでも私にとっては難しいです...私がやろうとしているのは、別のボタンで新しい開いたウィンドウを最大化することだけです..教えてください、私は何を間違っていますか?

<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' に追加し、2 番目の関数で 2 行目をコード maxWindow.resizeTo(screen.width, screen.height); で変更します。

于 2013-09-07T18:19:38.083 に答える