自定义对话框的问题

nyyswd1978 2013-07-29 10:34:57
本人新人 比较白
研究网上的一段关于自定义对话框的js代码

var Dialog = function()
{
var me = this;
this.MaskImage = null;
this.Content = null;
this.Text = null;
this.Container = null;
this.ImagePath = "img/dialog/";
this.posX = 0;
this.posY = 0;
this.IsDown = false;
this.Width = 300;
this.Height = 0;
this.DocVisibleWidth = 0;
this.DocVisibleHeight = 0;
this.DocMaxWidth = 0;
this.DocMaxHeight = 0;
this.ImgZIndex = 101;
this.DialogZIndex = 102;
this.ButtonOK = null;
this.ButtonCancel = null;
this.ButtonRetry = null;

this.Icon =
{
Close_Normal: this.ImagePath + "close_normal.png",
Close_Higthlight: this.ImagePath + "close_highlight.png",
Mask_Image: this.ImagePath + "mask.png",
Dialog_Icon: this.ImagePath + "icon.png"
};

this.Remove = function()
{
document.body.removeChild(this.Container);
document.body.removeChild(this.MaskImage);
}

this.OK = function()
{
me.Close();
}

this.Retry = function()
{

}

this.Close = function()
{
this.Hide();
}

this.Hide = function()
{
this.Container.style.display = "none";
this.MaskImage.style.display = "none";
}

this.MaskImage = document.createElement("img"); //这里我能理解。创建一个img的dom
this.MaskImage.style.position = "absolute";
this.MaskImage.style.left = 0;
this.MaskImage.style.top = 0;
this.MaskImage.src = this.Icon.Mask_Image; //北京遮蔽图
document.body.appendChild(this.MaskImage);



目前我隐约能看懂 对话框出现时候,代码规定了置背景的遮蔽图片。
问题是。我不想用图片来遮蔽背景。只想用一段滤镜代码来遮蔽背景。该如何写呢?
我想实现的背景滤镜效果的css代码如下:(类似于蒙上白纱的朦胧效果)

background-color:#FFF;
filter:alpha(opacity=50);
opacity:0.5;

该如何整合到js中呢?不会写。请指教。谢谢
...全文
702 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
wxdc 2013-07-30
  • 打赏
  • 举报
回复


     var bgObj = document.createElement("div");
    bgObj.setAttribute('id', 'bgDiv');
    bgObj.style.position = "absolute";
    bgObj.style.top = "0";
    bgObj.style.background = "#FFF";
    bgObj.style.filter = "alpha(opacity=50)";
    bgObj.style.opacity = "0.5";
    bgObj.style.left = "0";
    bgObj.style.width = "200px";
    bgObj.style.height = "200px";
    bgObj.style.zIndex = "100";
    document.body.appendChild(bgObj);
   this.Hide = function () {
        this.Container.style.display = "none";
        //this.MaskImage.style.display = "none";
        bgObj.style.display = "none"
    }


nyyswd1978 2013-07-30
  • 打赏
  • 举报
回复
谢谢。参考你的研究出来了。结贴

87,901

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧