0

如果之前有人问过这个问题,我很抱歉,

我只是对我的代码感到好奇:

function showPopup(file,wdth,hght) {
//height = 768 width = 1024
var w = wdth;
var h = hght;

var winWidth = w+'px';
var winHeight = h+'px';
var winTop = (screen.height/2)-(h/2);
var winLeft = (screen.width/2)-(w/2);

window.open(file,'Upload','top='+winTop+',left='+winLeft+',width='+winWidth+',height='+winHeight+',toolbar=1,resizeable=1,statusbar=1,scrollbar=1,location=1, fullscreen=1');

}

然后我用 HTML 运行它:

<input type="button" onClick="showPopup('preview.php', '1000', '1000')" value="Priview">

正如我在函数中设置的那样,打开的窗口仍然没有工具栏、状态栏、滚动条等。

有人帮我看看我的代码有什么问题吗?谢谢

4

2 回答 2

1
<html>
        <head>
                <title>Test Website</title>
                <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
                <script>
                        function showPopup(file,wdth,hght) {
                        //height = 768 width = 1024
                        var w = wdth;
                        var h = hght;

                        var winWidth = w;
                        var winHeight = h;
                        var winTop = (screen.height/2)-(h/2);
                        var winLeft = (screen.width/2)-(w/2);
                        window.open(file,'Upload','top='+winTop+',left='+winLeft+',width='+winWidth+',height='+winHeight+',toolbar=1,resizeable=1,statusbar=1,scrollbar=1,location=1, fullscreen=1');
                        }
                </script>
        </head>
<body>

        <input type="button" onClick="showPopup('preview.php', '500', '500')" value="Priview">


</body>
</html>
于 2013-03-15T04:05:32.220 回答
0

第二个参数 ('name') 是 'Upload' - 它应该是 '_blank'

或此处提到的其他受支持的值之一:http: //www.w3schools.com/jsref/met_win_open.asp

Paul Calabro 也是对的,您不需要“px”单位。

于 2013-03-15T04:31:25.130 回答