When I run it locally (desktop windows PC running Xampp server) it works perfectly.
However on my live website (Linux server) when I click on a sub meu item and go to another page the menu folds closed and does not remain open at the sub menu.
For an example go to and click 'hazardous area' - 'basics'
When I first added the script it worked perfectly, even live and although I thought I did not change anything fundamental or relevant it suddenly started this behaviour.
The menu is added in a DIV with a PHP include so it is the same script across all pages.
I also created a test page using your full code unaltered code and it did the same.
As it works locally I put it down to the interpretation and comparison of the web address and the link address rather than a script error
Can anybody point me to where or how this comparison is done so I can look at the specific variables.
I tried to work it out for myself but its difficult to follow the script.
I am a JavaScript newbie but have some programming experience.
Thanks in advance