function openUrl(url){ var h= screen.width; var w= screen.height-30;//去掉任务栏的高度(忘记用不用去掉IE工具栏高度了,此高度自行设定) window.open(url,"", "titlebar=yes,fullscreen=no,dependent=yes,height=h,width=w,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,channelmode=no,status=no,location=no,directories=no"); return ; } 更正一下4楼的回复,他限定到800×600的窗口大小了,楼主的想法是根据当前分辨率来设置大小
2 使用 js 读取屏幕的宽度和高度,然后调整显示的页面参数。
if(screen.width <= 800){
window.open(url,"",
"titlebar=yes,fullscreen=no,dependent=yes,height=600,width=800,top=0,left=0,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,channelmode=no,status=no,location=no,directories=no");
}
else{
var top_position = (screen.width - 800) / 2;
var left_position = (screen.height - 600) / 2;
window.open(url,"",
"titlebar=yes,fullscreen=no,dependent=yes,height=600,width=800,top="+top_position+",left="+left_position+",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,channelmode=no,status=no,location=no,directories=no");
}
return ;
}
window.screen.availWidth 返回当前屏幕宽度(空白空间)
window.screen.availHeight 返回当前屏幕高度(空白空间)
window.screen.width 返回当前屏幕宽度(分辨率值)
window.screen.height 返回当前屏幕高度(分辨率值)
var w= screen.height-30;//去掉任务栏的高度(忘记用不用去掉IE工具栏高度了,此高度自行设定)
window.open(url,"",
"titlebar=yes,fullscreen=no,dependent=yes,height=h,width=w,toolbar=no,menubar=no,scrollbars=yes,resizable=yes,channelmode=no,status=no,location=no,directories=no");
return ;
}
更正一下4楼的回复,他限定到800×600的窗口大小了,楼主的想法是根据当前分辨率来设置大小
用screen.width和screen.height
eg:
if((screen.width==1024)&&(screen.height==768))
在html中width="100%"和height="100%"这样用百分号就可以了阿