/    Sign up×
Community /Pin to ProfileBookmark

Toggle menu needs to link as well as toggle.

I have a few Javascript Toggle menus that work beautifully, but I would like the main link that you click on to toggle the menu open, I would like that to also redirect to a new page. Is this possible? I have the <href> tag in the link and it still only toggles the menu and doesn’t redirect the page. Here is the code for the menus:

<script type=”text/javascript” language=”Javascript”>
<!– Hide script from older browsers

function toggleMenu(currMenu) {
if (document.getElementById) {
thisMenu = document.getElementById(currMenu).style
if (thisMenu.display == “block”) {
thisMenu.display = “none”
}
else {
thisMenu.display = “block”
}
return false
}
else {
return true
}
}

// End hiding script –>
</script>

<img src=”<?= $webroot ?>images/arrow.gif”>&nbsp;&nbsp;<a href=”http://www.link.com” onClick=”return toggleMenu(‘menu1’)” onMouseClick=”closeAllOpenMenus()”>Page 1</a>

<span class=”menu” id=”menu1″>

<img src=”<?= $webroot ?>/images/bullet.gif” alt=”bullet”>&nbsp;<a href=”<?= $webroot ?>index.php?view=atp.main”>ATP</a><br>

<img src=”<?= $webroot ?>/images/bullet.gif” alt=”bullet”>&nbsp;<a href=”<?= $webroot ?>index.php?view=atp.faculty”>Faculty</a><br>

<img src=”<?= $webroot ?>/images/bullet.gif” alt=”bullet”>&nbsp;<a href=”<?= $webroot ?>index.php?view=atp.reachus”>How To Reach Us</a><br>
</span>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@Mr_JJun 29.2006 — If you remove the return from this

onClick="[B]return[/B] toggleMenu('menu1')"

the page will load but then if your loading a new page why toggle?
Copy linkTweet thisAlerts:
@lazerbrainsauthorJun 30.2006 — Thanks, that did the trick. I am using the toggle because I want the drop down to be open but I also want it to load a new page. I have checks in place to keep the toggle open on certain pages. I just couldn't get the link to work. Thanks for your help.
×

Success!

Help @lazerbrains spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...