Logged Out
Create an Account
Login:
Password:

Forgot your password?
problem with cookies

problem with cookies
[Back to Index]  [Bottom of Thread]
Thread Tags
Primary: [Advanced Layout]
Secondary: None
1 2 >>>
after working hours on the new layout ive stumbled upon a problem.

a couple of months ago carlpalmer of The New Beginning posted a script to remember if a menu was open or closed (u can check what i mean on his site: http://tnb.dkpsystem.com/forum.php)

he said we could use it so i did and now ive got a problem:

closing and opening the menu's work but the cookie function doesn't work for some reason. i have included an html file where my menu bar + the javascript is in (the javascript is normally external)


i hope someone can check it and tell me whats wrong because i don't seem to find it

--
designer of http://aszune.dkpsystem.com
As far as I can tell (I only looked very briefly)... you aren't using any of the functions to save the cookie.

Yes, you have the .JS file with the functions on it, but you aren't calling them anywhere.

It looks as if your Toggle Script sets the cookie, but now you have to read the cookie and use it. That would be done byt the following:

on your layout.html Page, change:


<body>



To this instead:

<body onload="readCookies()">
this unfortunately doesn't do the trick

--
designer of http://aszune.dkpsystem.com
Um... I'm looking at your Source for your current site... (not the linked file on this post, but the actual production site)

2 things:

1) Your <Body> tag still doesn't have the change I mentioned

2) You now have lost
<script type="text/javascript" src="http://dkpfiles.com/fate/files/showhide.js"></script>
in the source code, but you had it earlier. It is this .JS file that I used to review your functions, and it was included earlier, but is now missing.
i deleted it because i use this


and for some reason when i implement the menu hiding it doesn't show the rounded corners anymore so i took it away

--
designer of http://aszune.dkpsystem.com
My first thought kind of follows Noblekain's suggestion. For any javascript to work you need one of 2 things to happen. Either an event has to triger a function or the javascript must access and edit the DOM at the time the page loads.

It does appear that the "fsmenu.js" does try to access the DOM at load. But where I got completely lost was the "var" that starts at line 8, it was just insane. It is checking the browser type and version, looking for events, grabing an id(s), writing html, seting up a timer, creating the animation, and a host of other functions that should be split up for ease of editing and in this case diagnostics. I am guessing somewhere in all that it can't find a part of the DOM or a variable that it has beed told is there and as such it self terminates to prevent big errors.

I guess my thoughts after looking over your site carefully, are I do not see a reason to have a cookie set to remember if a menu is open or closed. The only times you use something like that is to leave a "slide" down menu open when they click to go to the next page. Even then there are other ways to handle that other that writing a cookie. Writing and rewriting a cookie everytime someone mouses over something seems to be a little bit of a missuse of cookies in my opinion.


I hope I didn't come across to harsh. I am a little frustrated, for you, as it looks like the guy who wrote the code was trying to hide how it works from everyone. And in the procces has made it an overly cumbersome batch of code that no one can easily help you with.

EDIT: oops looks like I should have refreshed the page before posting looks likeyou guys have a disscution going.
krik the fsmenu.js file is not what i'm refering to! that is for the slide down menu

i meant the other menu (on the left side) the one that contains the ventrilo stuff etc

that is in this file

sorry for the name but it is one of many versions

--
designer of http://aszune.dkpsystem.com
Sorry, I guess I just assumed the problem was with the menu in the header as it isn't working, at least not for me.

Ok now I looked at the code in your main site ( http://fate.dkpsystem.com ) and on your test page the only .js files I am seeing are:

fsmenu.js
nifty.js
final.js
wow.js
urchin.js

So, I looked up the file you linked and I see what your trying and there are several problems.

<span id="Ventrilo" class="hideMenu">


var ob = document.getElementById("ventrilo").style;
ob.display = 'block';


First, Ventrilo and ventrilo are as similar as water and fire in the eyes of CSS or javascript.

Second , I assume class="hideMenu" has the menu hidden and guess what. Since it is after id="Ventrilo" it will get priority over any style set to id="Ventrilo"

Third, do not use a span use a div, spans are used like so

<span style="color: #0000FF;">Hi, my handel is Kriknosnah.</span> <span style="color: #FF0000;">what is yours</span>


display something like this

Hi, my handel is Kriknosnah. what is yours

They allow you to apply widely differing styles to the same line of info without it being split into different lines. Divs are best used for distiguishing between different "blocks" of data.

That is a start. I have raid I have to help with. I will continue to look at the code to see what else I spot.
A couple things.

1) I agree with Krik about the Span thing... but since it is rendering right, You might as well leave things as is. I'm sure it took you awhile to get things to appear properly... no sense in messing it up now.

2) Attached is a new script for your Toggle as well as your Cookies. It is a very slightly morphed version of what I have on my site (http://apocalypse.dkpsystem.com).

In order to make this work, you must do the following:

1) Rename all your Open/Close images from 'menu1, menu2', etc. to be the same ID as your SPAN + 'Img'. (ex. CalendarImg, LoginImg, etc.)

2) Change your onclick function call to Toggle_Menu('Calendar'), Toggle_Menu('Login'), etc.

3) Give each Span class="MenuGroup". I don't care what's in this class, as long as the Class is used, and never changed.

4) Add <body onload="Page_Load(); Nifty_Init()" onunload="Page_Unload()">


One thing to note. This will absolutely work. However, you have a window.onload event declared for your Nifty corner script. This will likely get ignored if you aren't careful. What I did to counter that was to change the window.onload call in the Final.js file to be a function called Nifty_Init().
Then I made your Body tag call it directly after it collapses all the Left Menu.

Also it is important to understand that my code operates under the assumption that the menu by default is OPEN, and the only thing I afect are those that should be closed. Therefore, make sure your menu appears totally open by standard. Then my code will close those that should be closed.




ok i'll check into it!

just something i noticed (only checked firefox) when you open/close your menu's multiple times you get a weird effect: there is a huge blank area before u have the actual menu content

and the more u open/close the bigger it gets

--
designer of http://aszune.dkpsystem.com
Quote by borkjev
ok i'll check into it!

just something i noticed (only checked firefox) when you open/close your menu's multiple times you get a weird effect: there is a huge blank area before u have the actual menu content

and the more u open/close the bigger it gets


You won't have that problem. I'm abusing the TBODY tag... kinew I was doing it when I did, and Firefox doesn't like it. Instead though, you're using Spans, which will be fine. There aren't intended to be more than one TBody in a table, and you really aren't meant to change the display on it... I mean, the specification is there, but it's pretty substandard. I did it anyway, and the result you see is the problem. I just haven't gone back to change it yet.

Anyway, The script I gave you I modded a bit to work for you (without that problem). You should have no issues.
i looked a bit at your site's code and i did all you said and then it didn't work but after doing this (stole it from your site)

<a href="javascript: Toggle_Menu('Login')">
<div onClick="toggleMenu('Login')" class="MenuCat" style="position:relative; top:-20;" >
<center>
Login
</center>
</div>
</a>

Ok it worked on the test page and it also works on the good page but it doesnt save it with cookies to remember what i closed

--
designer of http://aszune.dkpsystem.com
Well it looks like Noblekain is the best one to help you figure this out, borkjev, as he has it on his site.

But I thought I would ask a question that may change both of you two's thinking. I have visited the Apocalypse website a couple time while working throuhg my guilds new site (and many others trying to come up with some ideas). And never noticed that you could collapse the menus in the left hand column. Nothing against the idea, I like it, but if you start with them open people don't realize they can close them. Also if you start with them closed you wouldn't need cookies neccesarily.

It's just a thought that falls more in a personal preference area than an actual critique. I have dealt with many sites over the years and making them user friendly is not easy. If you do decide to go with the open and then they can be closed option I would make an arrow, plus/minus sign or some graphic that would indicate they can be closed
Quote by borkjev
i looked a bit at your site's code and i did all you said and then it didn't work but after doing this (stole it from your site)

<a href="javascript: Toggle_Menu('Login')">
<div onClick="toggleMenu('Login')" class="MenuCat" style="position:relative; top:-20;" >
<center>
Login
</center>
</div>
</a>

Ok it worked on the test page and it also works on the good page but it doesnt save it with cookies to remember what i closed


First you can change it to this:


<div onClick="Toggle_Menu('Login')" class="MenuCat" style="position:relative; top:-20;" >
<center>
Login
</center>
</div>


That will work.

Notice you have both Toggle functions in your example.

Secondly, you don't need the "style" in the Div, unless you want it.

Thirdly, I noticed you still use the Final.js, not the NiftyFinal.js that I posted.

Fourthly, you didn't update your <Body> tag, so you aren't calling my Page_Load, and Page_Unload functions.
after looking into the code i saw it should change the image to menuopen.jpg or menuclose.jpg

it also currently doesnt do that for a reason

--
designer of http://aszune.dkpsystem.com
Krik. I don't necessarly disagree with your thinking. I mostly forced them open at first while I was debuggin my code, and well... it stuck. You can invert that and make them closed by default (in which case you'd want cookies to open them), which might be the better approach, because it makes peeps aware that there is an Open/Close functionality.
borkjev...

The Images thing is because I'm looking for the ID, and you've only populated the Image NAME. give all your images ID's that match the name, and you'll be set.
One more thing... If you post your MSN Instant Messenger, I'll be happy to help you real-time.
stefjeuuuh@hotmail.com

i'm currently online

--
designer of http://aszune.dkpsystem.com
Here's a new more generic Scripting File for the Show/Hide functions and Cookie functions.

It allows you to set the DEFAULT setting for your menus. (i.e. you can set all your menus to OPEN, and it will remember those that were closed... or you can default all your menus to closed, and it will remember those that are Open.


1 2 >>>
[Back to Index]  [Top of Thread]