对话框是网页中常用的显示信息的工具,所以我自己实现了一个小的对话框。

dialog =
{

createDialog:function(content, newId)
{
mask();
var dialogBox = document.createElement('div');
dialogBox.innerHTML = content;

if(!ctit.utility.isNull(newId))
{
dialogBox.id = newId;

}else
{
dialogBox.id = "__dialogBox__";
}
var width = 300;
var height = 500;
var left = parseInt((ctit.utility.getViewWidth() - width)/2 + document.documentElement.scrollLeft);
var top = parseInt((document.documentElement.clientHeight - height)/2 + document.documentElement.scrollTop);

Element.setStyle(dialogBox,
{position:"absolute", zIndex:1010, left: left + "px", top: top + "px", parseInt(width) + "px", height: parseInt(height) + "px"});
dialogBox.style.backgroundColor = "#fff";
document.body.appendChild(dialogBox);
dialog.keepON(dialogBox.id);
return dialogBox;
},

resetWidthHeight:function(id, width, height)
{
var o = $(id);

o.setStyle(
{parseInt(width)+"px", height:parseInt(height)+"px"});
},

fixedWH:function(id)
{
var o = $(id);
var width = 333;
var height = 555;

o.setStyle(
{parseInt(width)+"px", height:parseInt(height)+"px"});
},

keepON:function(id)
{
var o = $(id);
var width = Element.getWidth(o);
var height = Element.getHeight(o);
var left = parseInt((ctit.utility.getViewWidth() - width)/2 + document.documentElement.scrollLeft);
var top = parseInt((document.documentElement.clientHeight - height)/2 + document.documentElement.scrollTop);

o.setStyle(
{left:left+"px", top:top+"px"});
clearTimeout(dialog.timing);
dialog.timing = setTimeout("dialog.keepON('" + o.id + "');", 300);
},

removeDialog:function(id)
{
var o = $(id);
clearTimeout(dialog.timing);
document.body.removeChild(o);
unMask();
}
}