Hi good day!
I just want to know on how to center a new page window when click.. I have this java script below but it appears on top left. I want it to appear center of the screen on even in different resolution!

<a href="javascript:void(window.open('http://localhost/nonescostmpc/accnt_login.php','','width=350,height=220,left=0,top=0,resizable=no,menubar=no,location=no,status=no,scrollbars=no'))">

thank you!

Recommended Answers

All 2 Replies

Try this script..

<head>
<script>
function windowCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
</script>
</head>
<body>
<a href="#" onclick="windowCenter('pop_up_window_center.html', 'POPUP',400,400);">OPEN POPUP</a>
</body>

tnx..it works!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.