2011-03-16 95 views
1

我有一个Flash组件我想在访问者访问该网站时只显示一次,我觉得代码是正确的,但它似乎没有正常工作? Flash对象每次都显示出来。jquery.cookie无法正常工作?

<style media="screen" type="text/css"> 

#brotherhoodCta{ 
      position:fixed; 
      bottom:0; 
      left:0; 
      width:100%; 
      height:248px; 
      overflow:hidden; 
      z-index:10000000000; 
     } 

     #brotherhoodCta img{ 
      border:none; 
     } 

      #wrapper, 
      #persistent-bar, #persistent-bar:hover { 
       display:none; 
       position:fixed; 
       bottom:0; 
       left:0; 
       width:100%; 
       height:250px; 
       overflow:hidden; 
       } 

      #persistent-bar { 
       text-align: center; 
       width:100%; 
       } 
     </style> 



<script type="text/javascript"> 
jQuery.noConflict(); 
jQuery(document).ready(function() { 
    var COOKIE_NAME = 'nyr_brotherhood'; 
    var options = { path: '/', expiration: 1 }; 

     if (jQuery.cookie(COOKIE_NAME) == null) 
     { 
      showCta(); 
      jQuery.cookie(COOKIE_NAME, "viewed", options); 
     }  


    function showCta() 
    { 
     jQuery('#persistent-bar').show(); 
    } 
    }); 
    </script> 

<div id="brotherhoodCta"> 
<div id="persistent-bar"> 
<script type="text/javascript" charset="utf-8"> 
       // SWFObject Setup 

       // flash vars 
       var flashvars = {}; 

       // params 
       var params = {}; 
       params.menu = "false" 
       params.wmode = "transparent"; 

       //attributes 
       var attributes = {id: "PlayoffCTA"}; 

       // embed it 
       swfobject.embedSWF("http://rangers.nhl.com/v2/ext/playoffs-2011/RangersPlayoffCTA.swf", "persistent-bar", "100%", "250", "10.0.0", false, flashvars, params, attributes); 
      </script></div> 

+0

你到期值需要的日期定远的未来。 – 2011-03-16 20:41:21

回答

1

更改您的CSS来:

#persistent-bar { 
text-align: center; 
width:100%; 
display: none; 
} 
+1

我不知道是谁投了票,但答案是明智的。 ID为“persistent-bar”的DIV是始终显示的样式。在脚本中对可见性进行的唯一操作也会导致显示。答案会导致DIV开始隐藏,当条件适当时,JS会显示它。 – JAAulde 2011-03-16 21:47:26