2012-05-02 89 views
4

我用我的手風琴菜單從我的網站上提取了這個網站http://www.designchemical.com/lab/jquery-vertical-accordion-menu-plugin/examples/。如果我點擊主菜單相應的子菜單打開。如果我點擊它重定向到鏈接頁面的子菜單。但該頁面中的菜單不在opened state中。這是我的問題。我該如何糾正?手風琴菜單中的活動狀態

,我已經使用的內部腳本是

<script type="text/javascript"> 
$(document).ready(function($){ 
    $('#accordion-3').dcAccordion({ 
     eventType: 'click', 
     autoClose: false, 
     saveState: false, 
     disableLink: false, 
     showCount: false, 
     speed: 'slow' 
    }); 
}); 
</script> 

回答

0

在cookie

setCookie('state',$("#accordion-3").accordion('option','active')); 

而其他網頁上保存當前狀態重定向

$('#accordion-3').dcAccordion({ 
     active:getCookie('state'), /****activating the current state***/ 
     eventType: 'click', 
     autoClose: false, 
     disableLink: false, 
     showCount: false, 
     speed: 'slow' 
    }); 

/**cookie functionalities***/ 
function deleteCookie(name) { 
     setCookie(name,"",-1); 
    } 
    function setCookie(name,value,days) { 
     if (days) { 
      var date = new Date(); 
      date.setTime(date.getTime()+(days*24*60*60*1000)); 
      var expires = "; expires="+date.toGMTString(); 
     } 
     else expires = ""; 
     document.cookie = name+"="+value+expires+"; path=/"; 
    } 
    function getCookie(name) { 
     var nameEQ = name + "="; 
     var ca = document.cookie.split(';'); 
     for(var i=0;i < ca.length;i++) { 
      var c = ca[i]; 
      while (c.charAt(0)==' ') c = c.substring(1,c.length); 
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); 
     } 
     return null; 
    } 
+0

後,如果我用這個代碼菜單總是處於打開狀態。我只需要它在子菜單頁面處於打開狀態。 – designersvsoft