Thursday, April 8, 2010

Open and center pop-up window

Here is some code I used to open a pop-up window centered with no
address bar:

Put this in the head section:

<script type="text/javascript">
function openpopup(w,h)
{
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
window.open('frmUserSearch.aspx', '', 'toolbar=no, width='+w+',
height='+h+', top='+top+', left='+left, '');
}
</script>

Then on whatever control is going to open the pop up add:

OnClientClick="openpopup(300, 300)" -----You can change the size to fit
your needs.

Enjoy.

No comments: