IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Menu Remember State Using Cookies, Need some help with this.
DanBevan
post Dec 1 2005, 07:07 PM
Post #1


Newbie
*

Group: Members
Posts: 2
Joined: 29-November 05
Member No.: 2,853



Hi Everyone,

Does anyone know how to make the menu remember the state it was in when a user refreshes the page?

I have found a free menu with this function, but i have no clue how to get my DMB menu to do this or implement the code into my existing menu. I would prefer to use DMB as I like the customisability of it.

Thanks

Dan smile.gif

This is the code that does it but I am a dummy!!

<script language="JavaScript1.2">
<!--

function get_cookie(Name) {
//Get cookie routine by Shelley Powers
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
// if cookie exists
if (offset != -1) {
offset += search.length
// set index of beginning of value
end = document.cookie.indexOf(";", offset);
// set index of end of cookie value
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

var foldercontentarray=new Array()
var c=0

if (ns6){
for (i=0;i<document.getElementsByTagName("UL").length;i++){
if (document.getElementsByTagName("UL")[i].id=="foldinglist"){
foldercontentarray[c]=document.getElementsByTagName("UL")[i]
c++
}
}
}

if (get_cookie(window.location.pathname) != ''){
var openresults=get_cookie(window.location.pathname).split(" ")
for (i=0 ; i < openresults.length ; i++){
if (ns6){
foldercontentarray[openresults[i]].style.display=''
foldercontentarray[openresults[i]].previousSibling.previousSibling.style.listSty
leImage="url(open.gif)"
}
else{
foldinglist[openresults[i]].style.display=''
document.all[foldinglist[openresults[i]].sourceIndex -1].style.listStyleImage="url(open.gif)"
}
}
}

if (ns6||ie4){
var nodelength=ns6? c-1 : foldinglist.length-1
var nodes=new Array(nodelength)
var openones=''
}

function checkit(){
for (i=0 ; i <= nodelength ; i++){
if ((ns6&&foldercontentarray[i].style.display=='')||(ie4&&foldinglist[i].style.display==''))
openones=openones + " " + i
}
document.cookie=window.location.pathname+"="+openones
}

if (ns6||ie4)
window.onunload=checkit
//-->
</script>
Go to the top of the page
 
+Quote Post
DanBevan
post Dec 1 2005, 07:58 PM
Post #2


Newbie
*

Group: Members
Posts: 2
Joined: 29-November 05
Member No.: 2,853



I have read the guidance on this subject on http://software.xfx.net/utilities/dmbuilde...collapsible.htm but I don't think it resolves my problem, but It does make me think DMB is capable of resolving my problem.

The menu is for a site where users will choose which parts of the menu to have open at any one time. Ie. Its a text based game with about 11 groups, each having 5 commands beneath them. I would like DMB to be able to help me enable users to choose which groups they want open, and which they want closed, and for the menu to remember this state when the screen is refreshed. Is this possible? Can anyone help me do this??

thanks in advance

Dan
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd July 2014 - 07:20 AM