zoukankan      html  css  js  c++  java
  • js效果我的对话框实现

        对话框是网页中常用的显示信息的工具,所以我自己实现了一个小的对话框。
    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();
        }

    }
  • 相关阅读:
    Flash中先获取flv的尺寸然后再显示的方法
    雕虫小艺:Slider控件的制作(Flash)
    用几十行代码写一个可以在PC Web,PC桌面,安卓,iOS上运行的程序
    仰望星空,结果南辕北辙
    Flash播放mp4的两个问题:编码问题和需要下载完后才能播放的问题
    只学一点点:我的技术学习策略
    2012年计划
    提高ipad浏览器下大尺寸xml文件解析的性能
    html5/haXe开发偶感
    支点:技术选择的精髓
  • 原文地址:https://www.cnblogs.com/afxcn/p/902769.html
Copyright © 2011-2022 走看看