Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onLoad:toggleMenu

Status
Not open for further replies.

ebagtheftp

Technical User
Sep 10, 2007
1
AU
I'm making a website and in it, I have it so that the menu is hidden by default and when you click a button it shows the menu.

A simplified version of what i'm using is this:
Code:
<html>
<head>
<title>menu</title>
<script type="text/javascript">
function toggleMenu(list, img){
	var listElement = document.getElementById(list);
	listElement.style.display = (listElement.style.display == "none") ? "block" : "none";
	img.src = (img.src == "images/menu.jpg");
}
</script>
<head>
<body>
<div id="menu head"><img title="Click here to toggle the menu" src="images/menuhead.jpg" onclick="toggleMenu('menu', this)"/></div>
<div id="menu" style="display:none;"><img src="images/menu.jpg"/></div>
</body>
</html>

I'm trying to make it so that when you click a link in the menu it will load the new page with the menu showing.

It occurred to me that maybe appending a '#' to the end of the link, thus differentiating the 'toggled' link from the 'hidden' one, and then somehow making the page detect that and toggling the menu.

Assuming that makes any sense, I have no idea where to start...

I was thinking of something like this, but really I have no idea... <_<
Code:
<script type="text/javascript">
function getURL()
	{
	var url = document.URL;
	removeDomainName = url.split(".html");
	if ( # == DomainName ) return domainName;
	return true;
	document.onLoad.toggleMenu = ('menu', this);
	}
</script>
<body onLoad="getURL()">
I would really appreciate any help.
 
Hi

Code:
function getURL()
{
  var url = document.URL;
  removeDomainName = url.split(".html");
  if ( [red][b]'[/b][/red]#[red][b]'[/b][/red] == DomainName ) return domainName; // (1)
  return true;
  document.onLoad.toggleMenu = ('menu', this); // (2)
}
[tt](1)[/tt] a) From where comes that DomainName ?
[tt] [/tt] b) From where comes that domainName ?
[tt](2)[/tt] a) Will never be executed because you have an unconditioned [tt]return[/tt] before.
[tt] [/tt] b) From where comes that document.onLoad ?

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top