使FaceBox只显示一次

时间:2011-07-26 22:30:28

标签: jquery cookies facebox

现在我正在创建一个代码,其中Facebox(灯箱插件)仅为每个人显示一次。但它只是不起作用

我的代码是:

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<link href="http://weebuild.biz/resources/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css">
<script src="http://weebuild.biz/resources/facebox/facebox.js" type="text/javascript"></script>
<script type="text/javascript"> 
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox({
loadingImage : 'http://weebuild.biz/resources/facebox/loading.gif',
closeImage   : 'http://weebuild.biz/resources/facebox/closelabel.png'
      });
});
</script>
<script type="text/javascript"> 
      function getCookie(c_name){
 var i,x,y,ARRcookies=document.cookie.split(";");
 for (i=0;i<ARRcookies.length;i++){
   x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
   y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
   x=x.replace(/^\s+|\s+$/g,"");
   if (x==c_name){
     return unescape(y);
     }}}
 function setCookie(c_name,value,exdays){
 var exdate=new Date();
 exdate.setDate(exdate.getDate() + exdays);
 var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
 document.cookie=c_name + "=" + c_value;
 }
       $(document).ready(function(){
         // alert(document.cookie);
 var cookieyes=getCookie("comin223");
  if(cookieyes!==null&&cookieyes!==""){
      return false();
    }
    else{
      jQuery.facebox({ div: '#cookie_box' });
    setCookie("comin223","yes",365);
    }
  });
 </script> 
<style type="text/css">
  #whats-new p {
    margin-top:15px;
  }
  .dashed {
      border-top:1px dotted black;
    }
</style>
<div id="cookie_box" style="display:none;width:500px;"> 
  <span style="font-size:18px;font-weight:bold;">What's Coming Soon</span> 
   <div class="dashed"></div> 
  <p>We will soon have a Contact Us Button in between the Request Tool and Report Bug Button</p>
 <br>
  <p><b><span style="color:red;">NOTE: This will only show up once!</span></b></p>


</div> 

这是假设只做一次即将来临的盒子。问题是facebox无法正常工作,看起来设置正确。

1 个答案:

答案 0 :(得分:1)

首先,改变行

return false();

return false;

其次,改变行

if(cookieyes!==null&&cookieyes!==""){

if(cookieyes!==undefined&&cookieyes!==null&&cookieyes!==""){

排序!!!