Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-07-2011, 02:15 PM   PM User | #1
richardhoman
New to the CF scene

 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
richardhoman is an unknown quantity at this point
Difficult Javascript problem

Hello

I'm working on a website for a friend. The website can be found here: http://sidway.zonlicht.eu/ . Please take a closer look at the menu. When you hover your mouse over the options, a bar will float to that option. This bar will return to the 'contact' option in the menu when you stop hovering.

The problem here is as follows: The bar should return to the menu option which is linked to the page you are currently looking at. I.E.: When you click 'Media', you go to the corresponding page. And now the moving bar under the menu should go to 'Media' in the menu instead of 'Contact'. But it doesn't!

This is because the Javascript controlling the bar (which is called LavaLamp), cannot link the current page to a menu option. The script then falls back to the first menu option it finds, which is 'Contact'.

The reason is that i set up the site, aswell as the server to use ‘friendly’ urls, which means that for example:

http://sidway.zonlicht.eu/en/media is changed on the serverside to http://sidway.zonlicht.eu/en/index.php?p=media . This means that when you go to the first url, the server (as well and the php code in the php file) will think you opened the second url.
So i changed the menu href=”” options from “index.php?p=EXAMPLE” to “../EXAMPLE”. This way you end up on the same page, but with a user friendly url. The problem is that the Javascript controlling the bar, can now no longer link a page (which is now “/en/media”) to the menu item, which hrefs to “../media”. This is the reason it falls back to Contact, which is the first menu option you’ll find in the html code.
Can you help me alter the JavaScript code, so that the bar in the menu works, even with the userfriendly URL’s?
This is the Javascript: http://sidway.zonlicht.eu/scripts/lavalamp.js
The part of the code where the problem lies is between lines 288 and 309 <<--- I THINK !!.
The php file which uses the javascript is here: http://sidway.zonlicht.eu/en/index.php , the way to open this file in your browser is: http://sidway.zonlicht.eu/en/home .

Can you please help my to solve this problem? It has been bothering me for days and I simple can;t figure out a solution by myself. PLEASE help!

Kind Regards,
Richard Homan

Last edited by richardhoman; 03-07-2011 at 02:51 PM..
richardhoman is offline   Reply With Quote
Old 03-07-2011, 02:29 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
This isn't a Javascript problem at all. All you have to do is, on the server side, give the currently active <li> the CSS class "selectedLava". You shouldn't have any problems doing this, either, because you're already giving the currently active <li> the class "current_page_item", so just add "selectedLava" to that.
venegal is offline   Reply With Quote
Old 03-07-2011, 02:30 PM   PM User | #3
richardhoman
New to the CF scene

 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
richardhoman is an unknown quantity at this point
I already tried this, doesn't work...

Edit: implemented it in the site anyway, to show it really does not work.. http://sidway.zonlicht.eu/en/home/

Since this does not work, I thought the best way to solve this would be to edit the javascript code which selects the menu option. One possibility might be to look at the location the client browser is at, and taking the last part of the url, which would be home/media/contact/whatever, and look for this keyword in the hrefs in the menu..

That might work, right? I am just not familiar enough with JS to make such a code..

Last edited by richardhoman; 03-07-2011 at 02:48 PM..
richardhoman is offline   Reply With Quote
Old 03-07-2011, 02:45 PM   PM User | #4
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
You can't give a HTML tag two "class" attributes. If you want to give it two CSS classes, you have to put them into the same "class" attribute, separated by a space.
venegal is offline   Reply With Quote
Old 03-07-2011, 02:55 PM   PM User | #5
richardhoman
New to the CF scene

 
Join Date: Mar 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
richardhoman is an unknown quantity at this point
-.-' I feel like the biggest dumbsh*t in the world rightnow..

Thank you very much for your help in solving this problem!
richardhoman is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:06 PM.


Advertisement
Log in to turn off these ads.