我打开一个窗口,w=window.open('','', 'width=1000,height=700');
我希望这个窗口以 10/7 的比例调整大小。例如:500/350;100/70 ...
我已经有最大和最小尺寸:
var w;
function openwindow()
{
w=window.open('','', 'width=1000,height=700');
w.focus();
resize(w);
}
function resize(w_obj) {
w_obj.onresize = function(event) {
width = w_obj.innerWidth;
height = w_obj.innerHeight;
// if popup width is greather then 1000px
if (width > 1000) {
w_obj.resizeTo(1000,700);
}
// if popup height is greather then 700px
if(height >700) {
w_obj.resizeTo(1000,700);
}
if (width < 500) {
w_obj.resizeTo(500,350);
}
if(height < 350) {
w_obj.resizeTo(500,350);
}
}
}