Reputation: 33
When I use the funktion it opens up a new window up in the right corner of the screen. I want it in the center of the screen. How do I do that?
function f(){
var gid=function(i){return document.getElementById(i);};
var version_id=gid("two").value;
var arch_id=gid("three").value;
if( version_id ==='default' || arch_id === 'default'){return;}
window.open('images/' + version_id + '_' + arch_id + '.jpg', "_blank", "width=200, height=200" );
}
Upvotes: 1
Views: 32
Reputation: 4572
Try this code:
function f(){
var gid=function(i){return document.getElementById(i);};
var version_id=gid("two").value;
var arch_id=gid("three").value;
var width = 200;
var height = 200;
var left = (screen.width/2)-(width/2);
var top = (screen.height/2)-(height/2);
if( version_id ==='default' || arch_id === 'default'){return;}
window.open('images/' + version_id + '_' + arch_id + '.jpg', "_blank", 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+width+', height='+height+', top='+top+', left='+left );
}
Upvotes: 2