Javascript: Open new popup window at the center of the screen
Posted by Raj
Javascript: Open new popup window at the center of the screen
In this article,I will explain how to open new popup window center on screen using Javascript.
I have written java script function that opens a new popup window at the center of the screen.We are using window.open method of javascript
Syntax
window.open([URL], [Window Name],..... );
Example: Center popup Window
<html>
<head>
<script >
function PopupWindowCenter(URL, title,w,h)
{var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var newWin = window.open (URL, 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="javascript:void(0);" onClick ="PopupWindowCenter('http://www.example.com', 'PopupWindowCenter',600,700)">Open Center popup Window</a>
</body>
</html>
Now you can open a simple popup window at the center of the screen.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
center a pop-up window,
center a popup window,
center browser,
center div in window,
center pop up window,
center popup indow,
centered popup,
JQuery,
new popup window,
popup screen
.You can leave a response, or trackback from your own site.