//Modaldialog
function modalDialog() {
this.uri ="about:blank"; //地址
this.title = null; //标题
this.width = 400; //默认宽
this.height = 300; //默认高
this.borderColor = "black"; //边框颜色
this.borderWidth = 2; //边框宽度
this.callback = null; //回调方法
this.background = "black";
this.titleBackground = "silver";
}
modalDialog.prototype.url = this.uri; //这样不用扩展也是可以的但是在页面中只能提示找不到这个属性
modalDialog.prototype.title = this.title;
modalDialog.prototype.width = this.width;
modalDialog.prototype.height = this.height;
modalDialog.prototype.background = this.background;
modalDialog.prototype.borderWidth = this.borderWidth;
modalDialog.prototype.borderColor = this.borderColor;
modalDialog.prototype.titleBackground = this.titleBackground;
modalDialog.prototype.callback = this.callback;
//触发回调方法
modalDialog.prototype.call = function (callback) { if (callback != null) callback(this); if (this.callback != null) this.callback(); }
//显示
modalDialog.prototype.show = function () {
var js = window.js;
//在里面实现显示的细节
var x = js.bodyWidth, y = js.bodyHeight;
//先创建一个层遮罩整个body
var zdiv = "zdiv"; //遮罩层id
document.body.innerHTML += "
";
var mdiv = "mdiv"; //模态窗口层id
document.body.innerHTML += "
" +
//加上标题
(this.title != null ? "
" + this.title + "
" : "") +
"
";
}
modalDialog.prototype.close = function () {
document.body.removeChild(window.js.$("mdiv"));
document.body.removeChild(window.js.$("zdiv"));
}