Skip to content

Instantly share code, notes, and snippets.

@AnimeshShaw
Created October 2, 2013 04:13
Show Gist options
  • Select an option

  • Save AnimeshShaw/6789081 to your computer and use it in GitHub Desktop.

Select an option

Save AnimeshShaw/6789081 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
<script language="javascript">
var popupWindow = null;
function centeredPopup(url,winName,w,h,scroll){
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
popupWindow = window.open(url,winName,settings)
}
</script>
</head>
<body>
<p><a href="#" onclick="centeredPopup(this.href,'myWindow','500','300','yes');return false">Centered Popup</a></p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment