Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Add Onclick Events to Drupal Menu Links

Parent Feed: 

We've written before that menu links are one of the more basic features on a Drupal site.

One of our members wanted greater control over their menu links by using Javascript's Onclick events.

An Onclick event allows you to choose the action that happens when someone clicks a link.

I'm going to show you an easy way to make that possible, without any custom coding.

Step #1. Installation

Add Onclick Events to Drupal Menu Links

Step #2. Using Onclick Events

  • Go to Structure > Menus and find the menu links you want to modify.
  • Scroll down far enough and you will see an "Onclick" box. Here you can safely enter your Onclick events. These will be automatically added to your menu links on the frontend of the site.

About the author

Steve is the founder of OSTraining. Originally from the UK, he now lives in Sarasota in the USA. He was a teacher for many years before starting OSTraining. Steve wrote the best-selling Drupal and Joomla books.


Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web