当我使用该功能时,它将在屏幕的右上角打开一个新窗口。我想要它在屏幕中央。我怎么做?
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" );
}
试试下面的代码:
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 );
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句