jquery 弹出层

<style type="text/css">
*{margin:0;padding:0;list-style-type:none;}
body{font:12px/180% Arial, Helvetica, sans-serif,"宋体";}
a,img{border:0;}
a{color:#5e5e5e;text-decoration:none;}
a:hover{color:#3366cc;text-decoration:underline;}
/* box */
.box{position:absolute;width:600px;left:50%;height:auto;z-index:100;background-color:#fff;border:1px #8FA4F5 solid;padding:1px;}
.box h2{height:25px;font-size:14px;background-color:#3366cc;position:relative;padding-left:10px;line-height:25px;color:#fff;}
.box h2 a{position:absolute;right:5px;font-size:12px;color:#fff;}
.box .mainlist{padding:10px;}
.box .mainlist li{height:24px;line-height:24px;}
.box .mainlist li span{margin:0 5px 0 0;font-family:"宋体";font-size:12px;font-weight:400;color:#ddd;}
#TB_overlayBG{background-color:#666;position:absolute;z-index:99;left:0;top:0;display:none;width:100%;height:100%;opacity:0.5;filter: alpha(opacity=50);-moz-opacity: 0.5;}
</style>
<script type="text/javascript">
    $(function() {

        $(".showbox").click(function() {
            $("#TB_overlayBG").css({
                display: "block", height: $(document).height()
            });
            $(".box").css({
                left: ($("body").width() - $(".box").width()) / 2 - 20 + "px",
                top: ($(window).height() - $(".box").height()) / 2 + $(window).scrollTop() + "px",
                display: "block"
            });
        });

        $(".close").click(function() {
            $("#TB_overlayBG").css("display", "none");
            $(".box ").css("display", "none");
        });

    })
</script>
 

</head>
<body>
<p align="center" style="font-size:18px;font-family:微软雅黑;margin:100px;"><a href="javascript:void(0);" class="showbox">jquery制作点击按钮弹出层</a></p>
 
 <div id="TB_overlayBG"></div>
 <div class="box" style="display:none">
  <h2>jquery 特效列表<a href="#" class="close">关闭</a></h2>
  <div class="mainlist">
   <ul>
    <li><span>▪</span><a href="/jquery/items/2011-09-20/193.html" title="jquery 导航插件 一个动画导航下拉菜单Apycom软件的Java下拉菜单">jquery 导航插件 一个动画导航下拉菜单Apycom软件的Java下拉菜单</a></li>
    <li><span>▪</span><a href="/jquery/items/2011-09-20/191.html" title="jquery soChange 切换插件 支持焦点图片切换 选项卡切换 带按钮与分页索引按钮切换">jquery soChange 切换插件 支持焦点图片切换 选项卡切换 带按钮与分页索引按钮切换</a></li>
    <li><span>▪</span><a href="/jquery/items/2011-09-18/189.html" title="jquery 图片切换特效 鼠标点击左右按钮焦点图切换滚动">jquery 图片切换特效 鼠标点击左右按钮焦点图切换滚动</a></li>
    <li><span>▪</span><a href="/jquery/items/2011-09-18/187.html" title="jquery 分享代码在线制作鼠标一键复制url路径功能与分享信息">jquery 分享代码在线制作鼠标一键复制url路径功能与分享信息</a></li>
    <li><span>▪</span><a href="/jquery/items/2011-09-18/185.html" title="jquery 制作鼠标点击描点a标签返回顶部">jquery 制作鼠标点击描点a标签返回顶部</a></li>
   </ul>
  </div>
 </div>
 

</body>
</html>

 

//popup.js
(function() {
    var ptype = 1;

    function setcookie(cName, cExpires) {
        var zbj_ad_pop_cookie_time;
        try {
            zbj_ad_pop_cookie_time = parseFloat(cExpires) * 1;
        }
        catch (e) {
            zbj_ad_pop_cookie_time = 60 * 60;
        }
        if (isNaN(zbj_ad_pop_cookie_time))
            zbj_ad_pop_cookie_time = 60 * 60;
        var then = new Date();
        then.setTime(then.getTime() + zbj_ad_pop_cookie_time * 1000);
        document.cookie = cName + '=1;expires=' + then.toGMTString() + ';path=/;';
    }


    function upcookie(cname, ctime) {
        setcookie(cname, ctime);
    }

    var state = 0;
    ; (function() {
        var d = navigator.userAgent;
        var a = {};
        a.ver = {
            ie: /MSIE/.test(d),
            ie6: !/MSIE 7\.0/.test(d) && /MSIE 6\.0/.test(d) && !/MSIE 8\.0/.test(d),
            tt: /TencentTraveler/.test(d),
            i360: /360SE/.test(d),
            sogo: /; SE/.test(d),
            gg: window.google && window.chrome,
            _v1: '<object id="p01" width="0" height="0" classid="CLSID:6BF5' + '2A52-394' + 'A-1' + '1D3-B15' + '3-00' + 'C04F' + '79FAA6"></object>',
            _v2: '<object id="p02" style="position:absolute;left:1px;top:1px;width:1px;height:1px;" classid="clsid:2D' + '360201-FF' + 'F5-11' + 'd1-8D0' + '3-00A' + '0C95' + '9BC0A"></object>'
        };
        if (a.ver.ie || a.ver.tt) {
            document.write(a.ver._v1); document.write(a.ver._v2);
        }
        a.fs = null; a.fdc = null; a.timeid = 0; a.first = 1; a.url = ''; a.w = 0; a.h = 0;
        a.init = function() {
            try {
                if (typeof document.body.onclick == "function") {
                    a.fs = document.body.onclick; document.body.onclick = null
                }
                if (typeof document.onclick == "function") {
                    if (document.onclick.toString().indexOf('clickpp') < 0) {
                        a.fdc = document.onclick; document.onclick = function() {
                            a.clickpp(a.url, a.w, a.h)
                        }
                    }
                }
            } catch (q) { }
        };
        a.donepp = function(c, g) {
            if (g == 1 && (!a.ver.i360 && a.ver.ie6)) return;
            if (state) return;
            try {
                document.getElementById("p01").launchURL(c); state = 1; upcookie(zbj_ad_pop_cookie_name, zbj_ad_pop_cookie_time)
            } catch (q) { }
        };
        a.clickpp = function(c, e, f) {
            a.open(c, e, f); clearInterval(a.timeid); document.onclick = null;
            if (typeof a.fdc == "function") try { document.onclick = a.fdc } catch (q) { }
            if (typeof a.fs == "function") try { document.body.onclick = a.fs } catch (q) { }
        }
        a.open = function(c, e, f) {
            if (state) return;
            a.url = c; a.w = e; a.h = f;
            if (a.timeid == 0) a.timeid = setInterval(a.init, 100);
            var b = 'height=' + f + ',width=' + e + ',left=0,top=0,toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes';
            var j = 'window.open("' + c + '", "_blank", "' + b + '")';
            var m = null;
            try { m = eval(j) } catch (q) { }
            if (m && !(a.first && a.ver.gg)) {
                if (ptype != -1) { m.focus(); } else { m.blur(); window.focus(); }
                state = 1; upcookie(zbj_ad_pop_cookie_name, zbj_ad_pop_cookie_time);
                if (typeof a.fs == "function") try { document.body.onclick = a.fs } catch (q) { }
                clearInterval(a.timeid);
            } else {
                var i = this, j = false;
                if (a.ver.ie || a.ver.tt) {
                    document.getElementById("p01"); document.getElementById("p02");
                    setTimeout(function() {
                        var obj = document.getElementById("p02");
                        if (state || !obj) return;
                        try {
                            var wPop = obj.DOM.Script.open(c, "_blank", b);
                            if (wPop) {
                                if (ptype != -1) { wPop.focus(); } else { wPop.blur(); window.focus(); }
                                state = 1; upcookie(zbj_ad_pop_cookie_name, zbj_ad_pop_cookie_time);
                            } else if (a.ver.sogo) { state = 1; upcookie(zbj_ad_pop_cookie_name, zbj_ad_pop_cookie_time); }
                        } catch (q) { }
                    }, 200);
                }
                if (a.first) {
                    a.first = 0;
                    try { if (typeof document.onclick == "function") a.fdc = document.onclick } catch (p) { }
                    document.onclick = function() { i.clickpp(c, e, f) };
                    if (a.ver.ie) {
                        if (window.attachEvent) window.attachEvent("onload", function() { i.donepp(c, 1); });
                        else if (window.addEventListener) window.addEventListener("load", function() { i.donepp(c, 1); }, true);
                        else window.onload = function() { i.donepp(c, 1); };
                    }
                }
            }
        };
        a.getCookie = function(name) {
            var cookie = document.cookie;
            if (!name) {
                return cookie;
            } else {
                var pattern = "(?:; )?" + name + "=([^;]*);?";
                var rege = new RegExp(pattern);
                if (rege.test(cookie)) {
                    return decodeURIComponent(RegExp["$1"]);
                }
            }
        };
        window.zbj_ad_pop = a;
    })();
})();
var zbj_ad_pop_cookie_name = "zbj_ad_pop_cookie_name";
var zbj_ad_pop_cookie_time = 18 * 3600;
if (!zbj_ad_pop.getCookie(zbj_ad_pop_cookie_name)) {
    zbj_ad_pop.open("", window.screen.width, window.screen.height, "alwaysLowered");
}

 

 

 

转载于:https://www.cnblogs.com/cxlings/archive/2013/04/24/3041302.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值