一个自动适应不同分辨率的弹出类JPopup
程序员文章站
2022-07-06 16:31:26
...
/*================================= 弹出类 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===================================*/
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===================================*/