欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
您的位置:DIVCSS5首页 > HTML >

HTML基础必学列表

弹窗广告一天弹一次代码

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

         <meta name="description" content="">

         <meta name="keywords" content="">

         <title>弹窗广告一天弹一次</title>

<meta name="keywords" content="" />

<meta name="description" content="弹窗广告一天弹一次" />

         <style type="text/css">

                   *{

                            margin:0;

                            padding:0;

                   }

                  

                   .alert_windows{

                            display:none;

                            position:absolute;

                            z-index:10;

                            width:400px;

                            height:300px;

                            background:#566F93;

                   }

                  

                   .alert_windows span{

                            float:right;

                            width:30px;

                            height:30px;

                            text-align:center;

                            font:15px/30px Microsoft Yahei;

                            cursor:pointer;

                            color:#333;

                            background:lightblue;

                   }

                  

                   .alert_windows span:hover{

                            color:#EEE;

                            background:red;

                   }

         </style>

         <script type="text/javascript" src="js/jquery.min.js"></script>

         <script type="text/javascript" src="js/jquery.cookie.js"></script>

         <script type="text/javascript">

                   $(function(){

                            if($.cookie("isClose") != 'yes'){

                                     var winWid = $(window).width()/2 - $('.alert_windows').width()/2;

                                     var winHig = $(window).height()/2 - $('.alert_windows').height()/2;

                                     $(".alert_windows").css({"left":winWid,"top":-winHig*2});  //自上而下

                                     $(".alert_windows").show();

                                     $(".alert_windows").animate({"left":winWid,"top":winHig},1000);

                                     $(".alert_windows span").click(function(){

                                               $(this).parent().fadeOut(500);

                                               $.cookie("isClose",'yes',{ expires:1/8640});     //测试十秒

                                               //$.cookie("isClose",'yes',{ expires:1});            一天

                                     });

                            }

                   });

         </script>

</head>

 

<body>

        

         <div style="font-size:24px;width:360px;margin:40px auto;">提示:一天弹一次,关闭了就没了</div>

        

         <div class="alert_windows">

                   <span>X</span>

         </div>

</body>

</html>

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h17469.shtml

我要分享到:

必备CSS教程 Essential CSS Tutorials

必备HTML基础教程 Essential HTML Tutorials

 

如对文章有任何疑问请提交到DIV CSS论坛,或有任何网页制作CSS问题立即到CSS论坛发贴求解 或 直接DIVCSS5网页顶部搜索遇到DIVCSS疑问。
CSS教程文章修订日期:2017-01-13 11:22 原创:DIVCSS5
本文www.divcss5.com DIVCSS5版权所有。