How to make - When you click on a menu item, the list remained open?

barigain

Junior Member
Joined
Aug 23, 2012
Messages
100
Reaction score
12
Dear Webmasters, I can not deal with javascript, generally need to the menu when you click on the item subcategories remained open after the transition this category which crossed. To keep open the list, and I get it when going slams, here's the code:


tags in the head:
code:
Code:
<style type="text/css">
ol {display:none;}
</style>


<script type="text/javascript">
function shouNone(el){
var s;
el=el.getElementsByTagName("ol")[0].style;
s=el.display;
if(s=="none"||s==""){el.display="block";}
else{el.display="none";};
 };
</script>


the menu itself:
Code:
<li class="catsub" onclick="shouNone(this);" ondblclick="location.href='http://site.com/cat1.html'">
            <a href="javascript:void(0)">Cat 1</a>
            <ol class="catsubhref">
                <a href="/price/cat1/1/">Page 1</a>
                <a href="/price/cat1/2/">Page 2</a>
                <a href="/price/cat1/3/">Page 3</a>
            </ol>
        </li>
<li class="catsub" onclick="shouNone(this);" ondblclick="location.href='http://site.com/cat2.html'">
            <a href="javascript:void(0)">Cat 2</a>
            <ol class="catsubhref">
                <a href="/price/cat2/1/">Page 1</a>
                <a href="/price/cat2/2/">Page 2</a>
                <a href="/price/cat2/3/">Page 3</a>
            </ol>
        </li>

How to implement javascript?
Thanks!
 
You can do it through cookies.
I do so sometimes. page content is assigned to a thread or a custom attribute class. and then starting from this value is made active the desired menu item.
 
You can do it through cookies.
I do so sometimes. page content is assigned to a thread or a custom attribute class. and then starting from this value is made active the desired menu item.
What do you mean? How can I use cookies in Javascript for this page?..
 
I would never use js with the menus ! Specially inside the html tags ! :/
 
JavaScript can create cookies, read cookies, and delete cookies with the property document.cookie.
With JavaScript, a cookie can be created like this:

Code:
document.cookie="username=John Doe";

You can alo add an expiry date (in UTC or GMT time). By default, the cookie is deleted when the browser is closed:

Code:
document.cookie="username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 GMT";

With a path parameter, you can tell the browser what path the cookie belongs to. By default, the cookie belongs to the current page.

Code:
document.cookie="username=John Doe; expires=Thu, 18 Dec 2013 12:00:00 GMT;" path=/";
 
Back
Top