2011-03-16 48 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