472,811 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

Javascript Problem!

I am developing a site at http://www.nwlmi.org.uk

The problem lies with the CSS/XHTML Menu which relies on JavaScript to
open and close the sections. The parent sections open and close fine
but when you click on one of the subsection items and go to the desired
page the menu fails to remain open.

The javascript code is embeded inthe html for reference.

Is this a JS issue I wonder. The original script/code derived from
Alsacreations but there is no documentation to aid this problem.

Thanks in advance for any tips :)

Chris

Jul 5 '06 #1
4 1496

cedwa wrote:
I am developing a site at http://www.nwlmi.org.uk

The problem lies with the CSS/XHTML Menu which relies on JavaScript to
open and close the sections. The parent sections open and close fine
but when you click on one of the subsection items and go to the desired
page the menu fails to remain open.

The javascript code is embeded inthe html for reference.

Is this a JS issue I wonder. The original script/code derived from
Alsacreations but there is no documentation to aid this problem.
I do not see your script problem off hand; perhaps someone else will
find it. However, on your page, you state: "This site is valid XHTML
and CSS" near the bottom of the page. The code is written as xhtml 1.0
strict, and the code does validate at W3C. However, if you valadate at
the W3C using the extended version, you find that the content type
being served is text/html, not the correct one for xhtml which is
xhtml+xml or xml. The reason for this is that you are using the
extension .html which nearly all servers associalte with ordinary html.
To server xhtml, you have to define a mime type for xhtml at the server
and associate it with an extension such as .xhtml or .xml. Then you
will find you are serving xhtml. However you will also find that the
page will not work on IE6, because IE6 can not handle true xhtml. To
overcome this problem you either have to provide both html and xhtml
pages, or play with the header exchange, often using a php include, to
automatically rewrite the page as html when the header exchange
indicates that the browser will not support xhtml+xml. As now served,
your page would be much better written as html 4.01 strict. Your css
validates at the W3C, but there are many warnings listed concerning it.
The warning only means that certain css code you use might not produce
a desired effect in some cases and that you need to examine the code to
be certain that this is not the case. In other words, just because
something is correct from a code viewpoint, does not mean that it
always will have the effect that you had in mind.

Jul 5 '06 #2
Hi,

cedwa wrote:
I am developing a site at http://www.nwlmi.org.uk

The problem lies with the CSS/XHTML Menu which relies on JavaScript to
open and close the sections. The parent sections open and close fine
but when you click on one of the subsection items and go to the desired
page the menu fails to remain open.

The javascript code is embeded inthe html for reference.

Is this a JS issue I wonder. The original script/code derived from
Alsacreations but there is no documentation to aid this problem.

Thanks in advance for any tips :)

Chris
The menu doesn't remain open because you didn't tell it that it should:
You set the onload event of the page to execute show, which closes the
whole menu. However, by using

window.onload = show;

you will execute show without parameters. Thus no menu item will be
expanded.

If you want to preserve the state of the menu between postbacks, you
must preserve the information. When the page is reloaded, the whole
JavaScript code is erased and reloaded.

There are different ways to preserve information: cookies (dated or just
for the session), sending a hidden field to the server and then back to
the client (needs server logic), using the query string in the URL,
using the VIEWSTATE in ASP.NET. I tend to prefer cookies for this kind
of work, especially for "pure" client-side tasks. If your menu is built
on the server, however, then you can definitely use one of the other
techniques I mention (cookies might be disabled by the client.

I have a menu on my webpage http://www.galasoft-lb.ch which does pretty
exactly what you want. The code is still in pre-release stage, but you
can use these links. Feel free to copy if you want.

For cookies:
http://www.galasoft-lb.ch/myjavascri...kie/index.html

For the menu:
view-source:http://www.galasoft-lb.ch/script/gsl...000000D0003.js

The menu is also draggable and the position is saved. You don't need
this for your own menu, but in case you're interested, this is the
object which does this:

view-source:http://www.galasoft-lb.ch/script/gsl...000000D0001.js

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 5 '06 #3
Hi Laurent

Thank you so much for the information. Im afraid JavaScript is a
weakness for me :( And so are Cookies. Do I need to link to the
JavaScript file that creates the session cookie for it to work?

I see how it works very well for your menu when dragged - and this sort
of memory/session is what my client needs in order that the menu
remains open.

Is there a good source that details how to do this? I am lost in all
the code :(

Thanks again
Chris

Laurent Bugnion wrote:
Hi,

cedwa wrote:
I am developing a site at http://www.nwlmi.org.uk

The problem lies with the CSS/XHTML Menu which relies on JavaScript to
open and close the sections. The parent sections open and close fine
but when you click on one of the subsection items and go to the desired
page the menu fails to remain open.

The javascript code is embeded inthe html for reference.

Is this a JS issue I wonder. The original script/code derived from
Alsacreations but there is no documentation to aid this problem.

Thanks in advance for any tips :)

Chris

The menu doesn't remain open because you didn't tell it that it should:
You set the onload event of the page to execute show, which closes the
whole menu. However, by using

window.onload = show;

you will execute show without parameters. Thus no menu item will be
expanded.

If you want to preserve the state of the menu between postbacks, you
must preserve the information. When the page is reloaded, the whole
JavaScript code is erased and reloaded.

There are different ways to preserve information: cookies (dated or just
for the session), sending a hidden field to the server and then back to
the client (needs server logic), using the query string in the URL,
using the VIEWSTATE in ASP.NET. I tend to prefer cookies for this kind
of work, especially for "pure" client-side tasks. If your menu is built
on the server, however, then you can definitely use one of the other
techniques I mention (cookies might be disabled by the client.

I have a menu on my webpage http://www.galasoft-lb.ch which does pretty
exactly what you want. The code is still in pre-release stage, but you
can use these links. Feel free to copy if you want.

For cookies:
http://www.galasoft-lb.ch/myjavascri...kie/index.html

For the menu:
view-source:http://www.galasoft-lb.ch/script/gsl...000000D0003.js

The menu is also draggable and the position is saved. You don't need
this for your own menu, but in case you're interested, this is the
object which does this:

view-source:http://www.galasoft-lb.ch/script/gsl...000000D0001.js

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 6 '06 #4
Hi,

cedwa wrote:
Hi Laurent

Thank you so much for the information. Im afraid JavaScript is a
weakness for me :( And so are Cookies. Do I need to link to the
JavaScript file that creates the session cookie for it to work?
The cookie file can be added to your source code by using

<script type="text/javascript" src="scriptFolder/ccookie.js"></script>

Once you did that, you can use all the function which are defined inside
this file.

I see how it works very well for your menu when dragged - and this sort
of memory/session is what my client needs in order that the menu
remains open.

Is there a good source that details how to do this? I am lost in all
the code :(
The code I use to save my menu's state cannot really be reused for your
menu without adapting it. I was hoping you could do it, but without some
JavaScript knowledge, it's going to be tough.

I would help you, but I am going in holidays from wednesday until end of
july, so I won't have time. I recommend you to look for someone with a
little more JavaScript knowledge to help you out. Also, if you use
Venkman (google for it) together with Firefox, you can debug the code,
so you understand better what happens. You can also debug it with Visual
Studio and IE, in case you have it.

Thanks again
Chris
Sorry I cannot help more.
Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Jul 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Kai Grossjohann | last post by:
It seems that Ctrl-N in Mozilla opens a new empty browser window. That's fine, I don't need to do anything about it. But Ctrl-N in IE appears to clone the current window. Is there a way to...
53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
6
by: Alex Rast | last post by:
First of all, this is not a programming question. I'm a user, not programming in JavaScript. I'm not, however, a novice user or even a power user - I certainly know programming intimately as well...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.