一个自动适应不同分辨率的弹出类JPopup

/*================================= 弹出类 Popup{===================================*/
function JPopup(urlpath) {
this.url = urlpath;
this.defaultwidth = 366; //the width of the window
this.defaultheight = 400; //the height of the window
}

JPopup.prototype.status = 'no';
JPopup.prototype.defaultScreenRate_width = 1024; //the default width of the screen
JPopup.prototype.defaultScreenRate_height = 768; //the default height of the screen

JPopup.prototype.parseWidth = function(value) {
if(isNaN( parseInt(value) ))
return this.defaultwidth + this.defaultScreenRate_width / screen.availWidth -1;
else
return value + this.defaultScreenRate_width / screen.availWidth - 1;
}

JPopup.prototype.parseHeight = function(value) {
if(isNaN( parseInt(value) ))
return this.defaultheight + this.defaultScreenRate_height / screen.Height - 1;
else
return value + this.defaultScreenRate_height / screen.Height - 1;
}

JPopup.prototype.showDialog = function(width, height) { //window.showModalDialog
var width1 = this.parseWidth(width);
var height1= this.parseHeight(height);
showModalDialog( this.url, window, 'center:Yes; dialogWidth:'+ width1.toString() +'px; dialogHeight:'+ height1.toString() +'px; status:no;');
}

JPopup.prototype.show = function(width, height) { //window.open
this.show('replace', width, height, 'yes', 'yes', 'no');
}

JPopup.prototype.show = function(width, height, scrollbars, resizable) { //window.open
this.show('replace', width, height, scrollbars, resizable, 'no');
}

JPopup.prototype.show = function(target, width, height, scrollbars, resizable, toolbar) { //window.open
width = this.parseWidth(width);
height= this.parseHeight(height);
var left = this.centerLeft(width);
var top = this.centerTop(height);

open(this.url, target, 'left='+ left +';top='+ top +';status='+ this.status + '; width='+ width +'; height='+ height +'; scrollbars='+ scrollbars +'; resizable='+ resizable+ '; toolbar='+ toolbar +';');
}

JPopup.prototype.fullScreen = function() {
open(this.url, 'replace', 'fullscreen=yes; status='+ this.status + '; ');
}

JPopup.prototype.centerLeft = function(width) {
var screenWidth = screen.availWidth;
return ((screenWidth - width) / 2);
}

JPopup.prototype.centerTop = function(height) {
var screenHeight = screen.Height;
return ((screenHeight - height) / 2);
}
/*================================= }弹出类 Popup===================================*/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值