Open popup window in center position

To open popup window in center position of screen. Following function is useful.

function OpenWin()
{
var width = 300; //width of popup window
var height = 500; //height of popup window
var left = parseInt(((screen.width - width) / 2));
var top = parseInt(((screen.height - height) / 2));

var win = window.open('url','name','width=' + width + 'px,height=' + height + 'px,left=' + left + 'px,top=' + top + 'px');
}