I am using window.open to open a popup window like so:
<a href="http://path/to/url" onclick="window.open(this.href, 'sharegplus', 'height=485,width=700'); return false;" target="_blank">
I want this to be centered in the screen, but without having to use <script> inline code </script>
and merely enter whatever I need within onclick=""
. Can this be done?
This is a bad answer. a much better answer can be found here: window.open() on a multi-monitor/dual-monitor system - where does window pop up?
But in the meantime while i decide when i want to update this answer, this fiddle accounts for dual monitor setups: http://jsfiddle.net/w665x/138/
This might work for you. Not confident in it being entirely cross-browser, but close;
<html>
<head>
<script type="text/javascript">
function goclicky(meh)
{
var x = screen.width/2 - 700/2;
var y = screen.height/2 - 450/2;
window.open(meh.href, 'sharegplus','height=485,width=700,left='+x+',top='+y);
}
</script>
</head>
<body>
<a href="http://path/to/url" onclick="goclicky(this); return false;" target="_blank">blah</a>
</body>
</html>