利用JavaScript弹出div层,以及递归调用

function BOX_show(e,obj)//显示
{
    if(obj<24)
        document.cookie = "tdid="+obj;
    if(document.getElementById(e)==null)
    {
        return ;
    }
    var selects = document.getElementsByTagName('select');
    for(i = 0; i < selects.length; i++)
    {
        selects[i].style.visibility = "";
    }

    BOX_layout(e);
    window.onresize = function(){BOX_layout(e);} //改变窗体重新调整位置
    window.onscroll = function(){BOX_layout(e);} //滚动窗体重新调整位置
    document.onkeyup = function(event)
    {
        var evt = window.event || event;
        var code = evt.keyCode?evt.keyCode : evt.which;
        //alert(code);

        if(code == 27)
        {
            BOX_remove(e);
        }
    }
}

function BOX_remove(e)//移除
{
    window.onscroll = null;
    window.onresize = null;
    document.getElementById('BOX_overlay').style.display="none";
    document.getElementById(e).style.display="none";

    var selects = document.getElementsByTagName('select');
    for(i = 0; i < selects.length; i++)
    {
        selects[i].style.visibility = "visible";
    }
}

function BOX_layout(e)//调整位置
{
    var a = document.getElementById(e);

    if (document.getElementById('BOX_overlay')==null)//判断是否新建遮掩层
    {

        var overlay = document.createElement("div");
        overlay.setAttribute('id','BOX_overlay');
        document.body.appendChild(overlay);
    }

    document.getElementById('BOX_overlay').ondblclick=function(){BOX_remove(e);};
    //取客户端左上坐标,宽,高
    var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);

    var clientWidth;
    if (window.innerWidth)
    {
        clientWidth = window.innerWidth;
    }
    else
    {
        clientWidth = document.documentElement.clientWidth;
    }

    var clientHeight;
    if (window.innerHeight)
    {
        clientHeight = window.innerHeight;
    }
    else
    {
        clientHeight = document.documentElement.clientHeight;
    }

    var bo = document.getElementById('BOX_overlay');
    bo.style.left = scrollLeft+'px';
    bo.style.top = scrollTop+'px';
    bo.style.width = clientWidth+'px';
    bo.style.height = clientHeight+'px';
    bo.style.display="";
    //Popup窗口定位
    a.style.position = 'absolute';
    a.style.zIndex=999;
    a.style.display="";
}

function HiddenButton(e)
{
    e.style.visibility='hidden';
    e.coolcodeviousSibling.style.visibility='visible'
}
function tanchu(obj)  
{
if(obj==3)
{
    for(var i=1;i<11;i++)
    {
    if(i==9)
        {
            document.getElementById(i).className="style7";
            document.getElementById(i).ondblclick=function asdfs(){BOX_show('shortterm',obj)};
        }
    else if(i==10)
    {
        document.getElementById(i).className="style7";
        document.getElementById(i).ondblclick=function diyi(){BOX_show('updatesource',10)};
    }
    else
    {
        document.getElementById(i).className="FGray";
        document.getElementById(i).ondblclick="";
     }
    }
}
else if(obj==10)
{
    for(var j=1;j<19;j++)
    {
    if(j > obj)
        {
            switch(j)
            {
                case 11:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shiyi(){BOX_show('buysource',obj)};
                    break;
                case 12:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shier(){BOX_show('room',obj)};
                    break;
                case 13:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shisan(){BOX_show('buildline',obj)};
                    break;
                case 14:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shisi(){BOX_show('rebuildline',obj)};
                    break;
                case 15:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shiwu(){BOX_show('zhuanchan',obj)};
                    break;
                case 16:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shiliu(){BOX_show('bianmai',obj)};
                    break;
                case 17:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shiqi(){BOX_show('nextshengchan',obj)};
                    break;
                default:
                    document.getElementById(j).className="style7";
                    document.getElementById(j).ondblclick=function shiba(){BOX_show('updatesource',18)};
                    break;
            }
        }
    else
        {
            document.getElementById(j).className="FGray";
        }
    }
}
else if(obj==18)
{
    for(var m=1;m<24;m++)
    {
    if(m > obj)
        {
        switch(m)
            {
                case 19:
                case 20:
                    document.getElementById(m).className="style7";
                    document.getElementById(m).ondblclick=function ershi(){BOX_show('procreate',obj)};
                    break;
                case 22:
                    document.getElementById(m).className="style7";
                    document.getElementById(m).ondblclick=function ershi(){BOX_show('marketcreate',obj)};
                    break;
                case 23:
                    document.getElementById(m).className="style7";
                    document.getElementById(m).ondblclick=function ershi(){BOX_show('iso',obj)};
                    break;
                default:
                    document.getElementById(m).className="style7";
                    document.getElementById(m).ondblclick=function eryi(){BOX_show('procreate',obj)};
                    break;
            }
        }
    else
        {
            document.getElementById(m).className="FGray";
        }
    }
}
}  

 

 

 

 

这是调用JavaScript的语句:

<td class="style7" ondblclick="BOX_show('longterm',this.id)" id="3">
                    <asp:Image ID="Image13" runat="server" ImageUrl="~/image/1.jpg" />
                </td>

posted @ 2010-05-06 08:23  j2ee技术  阅读(241)  评论(0编辑  收藏  举报