Plipus Tel
Plipus Tel

Reputation: 755

Javascript Opening New Window

I'm sorry if this question has been asked before,

I'm just curious with my code:

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');

}

Then I run it with HTML:

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

The opening window still donsn't have toolbar, statusbar, scrollbar, etc as I set inside my function.

Anybody help me what's wrong with my code? Thx

Upvotes: 0

Views: 235

Answers (2)

Paul Calabro
Paul Calabro

Reputation: 1906

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

Upvotes: 1

Mupps
Mupps

Reputation: 346

the second parameter ('name') is 'Upload' - it should be '_blank'

or one of the other supported values mentioned here: http://www.w3schools.com/jsref/met_win_open.asp

Paul Calabro is also right, you do not need the "px" units.

Upvotes: 0

Related Questions