现在的位置: 首页 > 综合 > 正文

[原创] PopUp特效

2013年02月25日 ⁄ 综合 ⁄ 共 3661字 ⁄ 字号 评论关闭
/*
    格式:set oPopUp = new PopUp(strHTML,Speed,Width,Height,Left,Top)
    参数说明:    strHTML        弹出窗口的HTML内容
                Speed        MSN和BOOM方式弹出的速度,1为最快
                Width        弹出窗口的宽度
                Height        弹出窗口的高度
                Left/Top    弹出窗口的位置
    以上参数要按顺序填写,可以省略最后的参数,或者全部不填
    相对应的属性可以用PopUpWindow.HTML,PopUpWindow.Speed,PopUpWindow.Width ....来设置
*/

function ClassPopUp (){
    this.HTML="";
    this.Speed=1;        //显示速度,现在已经是最快了
    this.Width=100;
    this.Height=100;
    this.Left=100;
    this.Top=100;
    this.m_PopUp=window.createPopup();
    if(arguments.length>0)    this.HTML=arguments[0];
    if(arguments.length>1)    this.Speed=parseInt(arguments[1]);
    if(arguments.length>2)    this.Width=parseInt(arguments[2]);
    if(arguments.length>3)    this.Height=parseInt(arguments[3]);
    if(arguments.length>4)    this.Left=parseInt(arguments[4]);
    if(arguments.length>5)    this.Top=parseInt(arguments[5]);
    with(this.m_PopUp.document.body.style){
        border="none";
        backgroundColor="white";
        padding="0px";
        margin="0px";
        fontSize="12px";
    }
}
//////////////////////////////////////
var PopUpWindow=new ClassPopUp();    //    全局变量 所有的弹出窗口都公用对象
var m_Left=0;                        //全局变量:当前x位置
var m_Top=0;                        //全局变量:当前y位置
var m_Width=0;                        //全局变量:屏幕宽度
var m_Height=0;                        //全局变量:当前高度
var m_sWidth=screen.width;            //全局变量:屏幕宽度
var m_sHeight=screen.height;        //全局变量:屏幕高度
var m_Timer=null;                    //全局变量:定时器
var m_Showing=false;                //全局变量:正在显示
//直接显示
//调用方式:DirectShowPopUp();
function DirectShowPopUp(){
    PopUpWindow.m_PopUp.document.body.innerHTML=PopUpWindow.HTML;
    PopUpWindow.m_PopUp.show(PopUpWindow.Left,PopUpWindow.Top,PopUpWindow.Width,PopUpWindow.Height);
}
/////////////////////////////////////////////
// 象MSN提示窗口一样在右下脚升起
// 调用方式:MSNShowPopUp();
/////////////////////////////////////////////
function MSNShowPopUp(){
    if(!m_Showing){    //初始化
        m_Height=0;
        m_Width=PopUpWindow.Width;
        m_Left=m_sWidth-m_Width-2;
        m_Top=m_sHeight-2;
        PopUpWindow.m_PopUp.document.body.innerHTML=PopUpWindow.HTML;
        m_Showing=true;
        m_Timer=window.setTimeout("MSNShowPopUp()",PopUpWindow.Speed);
    }else{
        if(m_Height<=PopUpWindow.Height){
            PopUpWindow.m_PopUp.show(m_Left,m_Top,m_Width,m_Height);
            m_Height+=5;
            m_Top-=5;
            m_Timer=window.setTimeout("MSNShowPopUp()",PopUpWindow.Speed);
        }else{
            window.clearTimeout(m_Timer);
            m_Showing=false;
            m_Timer=null;
            return;
        }
    }
}
////////////////////////////////////////////
//在屏幕中间从小到大弹出
//调用方式:BoomShowPopUp();
////////////////////////////////////////
function BoomShowPopUp(){
    if(!m_Showing){    //初始化
        m_Width=1;
        m_Height=1;
        m_Left=m_sWidth/2;
        m_Top=m_sHeight/2;
        PopUpWindow.m_PopUp.document.body.innerHTML=PopUpWindow.HTML;
        m_Showing=true;
        m_Timer=window.setTimeout("BoomShowPopUp()",PopUpWindow.Speed);
    }else{
        if(m_Width<=PopUpWindow.Width || m_Height<=PopUpWindow.Height){
            PopUpWindow.m_PopUp.show(m_Left,m_Top,m_Width,m_Height);
            if(m_Width<=PopUpWindow.Width){
                m_Width+=8;
                m_Left-=4;
            }
            if(m_Height<=PopUpWindow.Height){
                m_Height+=8;
                m_Top-=4;
            }
            m_Timer=window.setTimeout("BoomShowPopUp()",PopUpWindow.Speed);
        }else{
            window.clearTimeout(m_Timer);
            m_Showing=false;
            m_TImer=null;
            return;
        }
    }
}

抱歉!评论已关闭.