2011-06-16 86 views
0

我創建了大多數用戶通過Internet Explorer訪問的切換頁面,只有保存切換最後狀態的cookie無法工作。我曾嘗試使用Intellectual Tortoise的修復功能,這隻能打破切換功能。在閱讀了關於cookies的W3C網站上的信息後,我留下了一個鹿頭大燈的表達。jQuery Cookie切換不適用於Internet Explorer

我的問題是:

  1. 最後的狀態是無法在Internet Explorer的瀏覽器,任何版本。
  2. 我希望這個狀態能在任何瀏覽器中堅持並永不過期。

的JS:

/toggle/ 
    $(document).ready(function(){ 
    $(".toggle_container").show(); 
    $("h2.trigger").toggle(function(){ 
    $(this).addClass("active"); 
    }, function() { 
    $(this).removeClass("active"); 
    }); 
    $("h2.trigger").click(function(){ 
    $(this).next(".toggle_container").slideToggle("slow,"); 
    }); 
    }); 

    /cookies/ 
    $(".toggle_container").each(function() { 
    $(this).toggle($.cookie('show-' + this.id) != 'collapsed'); 
    }); 
    $(".trigger").click(function() { 
    var tc = 
    $(this).toggleClass("active").next(".toggle_container").slideToggle("slow", function() { 
    $.cookie('show-' + $(this).attr("id"), $(this).is(":hidden") ? 'collapsed' : 'expanded');   
    }); 
    return false; 
    }); 

與僱主要求的責難HTML:

 <h2 class="trigger"><a href="#">Production</a></h2> 
<div class="toggle_container" id="pd"> 
    <div class="block"> 
     <table cellspacing="0" cellpadding="0" border="0"> 
      <tr> 
       <td>Staff</td> 
       <td>PD</td> 
       <td><a href="https://snip/">https://snip/</a></td> 
      </tr> 
      <tr> 
       <td>Service</td> 
       <td>PD</td> 
       <td><a href="https://snip/">https://snip/</a></td> 
      </tr> 

在此先感謝您的幫助。

+0

您使用的是什麼版本的cookie插件? – doctorless 2011-06-16 16:46:35

+0

我更新到最新的cookie版本,最後一個狀態在IE中保持不可用狀態。 – Sanden 2011-06-16 18:28:45

+0

我剛剛拿出所有的cookie代碼,最後一個狀態繼續在Firefox中工作,所以我懷疑cookie代碼是否貢獻了一切。 – Sanden 2011-06-16 18:37:21

回答

1

我找到了一個解決方案,我的問題是相似的。我忘了把{ path: "/" }英寸。

$.cookie("DoNotShowGettingStartedDialog", true, { path: "/" }); 
相關問題