473,327 Members | 2,069 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 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 1513

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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.