4

I used accordion menu for my web page which is extracted from this site http://www.designchemical.com/lab/jquery-vertical-accordion-menu-plugin/examples/.If i click the main menu corresponding sub menu opens. If i click the submenu it redirected to the linked page. But the menu is not in opened state in that page. This is my problem. How can i correct that?

The internal script that i have used is

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

1 回答 1

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;
    }
于 2012-05-02T11:16:34.930 回答