此方法可通用,项目开发中经常要用到:
复制代码 代码如下:
//w:宽,h:高,url:地址,tag:标记
function showwin(w, h, url, tag) {
var t = (screen.height - h) / 2; //离顶部距离
var l = (screen.width - w) / 2; //离左边距离
window.open(url, tag, width= + w + ,height= + h + ,top= + t + ,left= + l + ,location=0);
}
//路径地址,window对象,宽,高
function open_dialog(url, win,width, height) {
var return_value;
var itop2 = (window.screen.availheight - 20 - height) / 2;
var ileft2 = (window.screen.availwidth - 10 - width) / 2;
var height2 = height - 50;
if (document.all && window.print) {
return_value = window.showmodaldialog(url, win, dialogleft: + ileft2 + px;dialogtop: + itop2 + px;dialogwidth: +
width + px;dialogheight: + height + px;center:yes;status:no;scroll:no;help:no;);
}
else {
window.open(url, win, top= + itop2 + ,left= + ileft2 + ,width= + width + px,height= + height2 +
px,resizable=0,scrollbars=0,location=0);
}
}