弹框只弹一次(cookie)

1.引入jquery.cookie.js

2.实现代码

<script type="text/javascript">
    jQuery(function($) {
     //查询是否存入cookie
var hasread = $.cookie('popoutCookie');
     //cookie为空则调用弹框方法 并设置cookie
if(hasread == undefined || hasread == 'undefined') { userNotification(); var m = new Date(); var date = new Date(m.getTime() + 30*60*1000);
         //设置cookie有效时间为半个小时 $.cookie('
popoutCookie','colse',{expires:date,path:'/'});
     }
   });

   //弹框
   function userNotification()
   {

      window.parent.openLayer({title:"公告信息",url:"${_path}/user/admin/notification/userNotification"});

    }

</script>
posted @ 2019-12-30 11:14  不负青春i  阅读(364)  评论(0编辑  收藏  举报