JMC
JMC

Reputation: 1697

Hide a div after the user clicks on a child menu item

I'm working with a javascript menu and need help hiding the menu after the user clicks a link in the child menu. The menu works well out of the box, except when the user clicks the back button on their browser it remains stuck open.

The code that hides the child menu:

divref.style.visibility = "hidden";

I think it needs to go in this section of code:

this.finishOpeningChild = function(divref, ulref, maxwidth) {
    this.isChildMenuOpen = true;
    this.isChildMenuClosed = false;
    ulref.style.left = "0px";
    divref.style.width = maxwidth + "px";

}

How do I make the browser look for the onClick scenario then call: divref.style.visibility = "hidden"; in this situation?

Upvotes: 0

Views: 162

Answers (1)

farinspace
farinspace

Reputation: 8791

Not sure in what context this is all running, but perhaps you have a statement on the page which checks to see if the menu is open, and closes it if it is, this would happens on page load ... so if the user clicks the back button and ends up on the page the below check would run ...

if ('hidden' != divref.style.visibility) divref.style.visibility = 'hidden';

Upvotes: 1

Related Questions